Skip to content

Commit

Permalink
Release v1.1.3
Browse files Browse the repository at this point in the history
- feat-be: 프로세스 목록 조회 API 필드 추가 (#811)
- fix-be: 프로세스 목록 조회 API 정렬 적용 방식 변경 (#834)
- feat-be: refresh token 구현 (#816)
- fix-be: github action secret 추가 (#844)
- chore-be: 무중단 배포 actions workflow 설정 변경 (#845)
- feat-be: Redis 로컬 환경 설정 (#822)
- chore-be: prod 환경 docker-compose.prod.yml 수정 (#858)
  • Loading branch information
Dobby-Kim authored Oct 21, 2024
1 parent f95f65b commit 9604c44
Show file tree
Hide file tree
Showing 51 changed files with 1,330 additions and 291 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/be-cd_dev-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,24 @@ jobs:
# Security settings
JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}
JWT_TOKEN_EXPIRE_CYCLE=${{ secrets.JWT_TOKEN_EXPIRE_CYCLE }}
ACCESS_TOKEN_EXPIRE_CYCLE=${{ secrets.ACCESS_TOKEN_EXPIRE_CYCLE }}
REFRESH_TOKEN_EXPIRE_CYCLE=${{ secrets.REFRESH_TOKEN_EXPIRE_CYCLE }}
JWT_SIGN_ALGORITHM=${{ secrets.JWT_SIGN_ALGORITHM }}
# Cookie settings
COOKIE_ACCESS_TOKEN_KEY=${{ secrets.COOKIE_ACCESS_TOKEN_KEY }}
COOKIE_REFRESH_TOKEN_KEY=${{ secrets.COOKIE_REFRESH_TOKEN_KEY }}
COOKIE_HTTP_ONLY=${{ secrets.COOKIE_HTTP_ONLY }}
COOKIE_SECURE=${{ secrets.COOKIE_SECURE }}
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN }}
COOKIE_PATH=${{ secrets.COOKIE_PATH }}
COOKIE_SAME_SITE=${{ secrets.COOKIE_SAME_SITE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
# Redis
REDIS_PORT=${{ secrets.REDIS_PORT }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
EOF
# - name: Check if MySQL container is running
Expand Down
271 changes: 246 additions & 25 deletions .github/workflows/be-cd_prod-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ name: BE/CD - [PROD] Build & Deploy

on:
workflow_dispatch:
push:
branches: be/release
inputs:
release-ver:
description: 'Release version tag (ex. v0.0.1)'
required: true
rollback-ver:
description: 'Rollback version tag (ex. v0.0.0)'
required: true

jobs:
build:
Expand Down Expand Up @@ -42,15 +47,10 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get current date and time
id: datetime
run: |
echo "datetime=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
- name: Image build and push
run: |
docker build --build-arg PROFILE=prod -t ${{ secrets.DOCKER_REPO_NAME }}/cruru:prod-${{ steps.datetime.outputs.datetime }} --platform linux/arm64 .
docker push ${{ secrets.DOCKER_REPO_NAME }}/cruru:prod-${{ steps.datetime.outputs.datetime }}
docker build --build-arg PROFILE=prod -t ${{ secrets.DOCKER_REPO_NAME }}/cruru:${{ inputs.release-ver }} --platform linux/arm64 .
docker push ${{ secrets.DOCKER_REPO_NAME }}/cruru:${{ inputs.release-ver }}
- name: Upload docker-compose yaml script to artifact
uses: actions/upload-artifact@v4
Expand All @@ -59,8 +59,6 @@ jobs:
path: |
${{ github.workspace }}/backend/docker-compose.prod.yml
${{ github.workspace }}/backend/promtail-config.yml
outputs:
BUILD_VERSION: ${{ steps.datetime.outputs.datetime }}
deploy:
environment: prod
Expand All @@ -76,6 +74,82 @@ jobs:
run:
working-directory: backend
steps:

- name: Set reviewer and sender variables
run: |
ASSIGNEE_LOGIN=${{ github.event.sender }}
echo "SENDER_SLACK_ID=${ASSIGNEE_LOGIN@L}" >> ${GITHUB_ENV}
- name: 배포시작 알림
uses: slackapi/[email protected]
with:
channel-id: C07S8K0PHTQ
payload: |
{
"blocks": [
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": "🚀 운영 배포 시작 🚀",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*배포자:*\n <@${{ env.SENDER_SLACK_ID }}>"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "🚀 *배포 버전:*\n${{ inputs.release-ver }}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "🚀 *롤백 버전:*\n${{ inputs.rollback-ver }}"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "🕹️ Action 실행 현황 🕹️",
"emoji": true
},
"value": "PR_LINK",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "actionId-1"
}
]
},
{
"type": "divider"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Set docker-compose YAML script to runner
uses: actions/download-artifact@v4
with:
Expand All @@ -87,7 +161,7 @@ jobs:
cat <<EOF > .env
# Docker Hub info from Github Secrets
DOCKER_REPO_NAME=${{ secrets.DOCKER_REPO_NAME }}
DOCKER_IMAGE_VERSION_TAG=prod-${{ needs.build.outputs.BUILD_VERSION }}
DOCKER_IMAGE_VERSION_TAG=${{ inputs.release-ver }}
# DB Configuration secrets info from Github Secrets
DB_PORT=${{ secrets.DB_PORT }}
Expand All @@ -100,14 +174,15 @@ jobs:
# DB server configuration secrets info from Github Secrets
APP_IP_ADDRESS=${{ secrets.APP_IP_ADDRESS }}
SERVER_BINDING_PORT=${{ secrets.SERVER_BINDING_PORT }}
SERVER_PORT=${{ secrets.SERVER_PORT }}
SUBNET=${{ secrets.SUBNET }}
BLUE_SERVER_BINDING_PORT=${{ secrets.BLUE_SERVER_BINDING_PORT }}
GREEN_SERVER_BINDING_PORT=${{ secrets.GREEN_SERVER_BINDING_PORT }}
BLUE_SERVER_PORT=${{ secrets.BLUE_SERVER_PORT }}
GREEN_SERVER_PORT=${{ secrets.GREEN_SERVER_PORT }}
# Monitoring configuration server info from Github secrets
MONITORING_INSTANCE_ADDR_LOKI_PORT=${{ secrets.MONITORING_INSTANCE_ADDR_LOKI_PORT }}
MONITORING_BINDING_PORT=${{ secrets.MONITORING_BINDING_PORT }}
MONITORING_PORT=${{ secrets.MONITORING_PORT }}
BLUE_MONITORING_BINDING_PORT=${{ secrets.BLUE_MONITORING_BINDING_PORT }}
GREEN_MONITORING_BINDING_PORT=${{ secrets.GREEN_MONITORING_BINDING_PORT }}
MONITORING_BASE_PATH=${{ secrets.MONITORING_BASE_PATH }}
MONITORING_PROFILE=${{ secrets.MONITORING_PROFILE }}
Expand All @@ -121,25 +196,171 @@ jobs:
# Security settings
JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}
JWT_TOKEN_EXPIRE_CYCLE=${{ secrets.JWT_TOKEN_EXPIRE_CYCLE }}
ACCESS_TOKEN_EXPIRE_CYCLE=${{ secrets.ACCESS_TOKEN_EXPIRE_CYCLE }}
REFRESH_TOKEN_EXPIRE_CYCLE=${{ secrets.REFRESH_TOKEN_EXPIRE_CYCLE }}
JWT_SIGN_ALGORITHM=${{ secrets.JWT_SIGN_ALGORITHM }}
# Cookie settings
COOKIE_ACCESS_TOKEN_KEY=${{ secrets.COOKIE_ACCESS_TOKEN_KEY }}
COOKIE_REFRESH_TOKEN_KEY=${{ secrets.COOKIE_REFRESH_TOKEN_KEY }}
COOKIE_HTTP_ONLY=${{ secrets.COOKIE_HTTP_ONLY }}
COOKIE_SECURE=${{ secrets.COOKIE_SECURE }}
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN }}
COOKIE_PATH=${{ secrets.COOKIE_PATH }}
COOKIE_SAME_SITE=${{ secrets.COOKIE_SAME_SITE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
# Redis
REDIS_PORT=${{ secrets.REDIS_PORT }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
EOF
- name: Stop and remove existing containers
- name: Run zero down time Deploy Script
run: |
sudo docker-compose -f docker-compose.prod.yml down --rmi all
chmod +x ../deploy.sh
../deploy.sh
- name: Deploy docker container
run: |
sudo docker-compose --env-file .env -f docker-compose.prod.yml up -d
- name: 배포시작 알림
uses: slackapi/[email protected]
with:
channel-id: C07S8K0PHTQ
payload: |
{
"blocks": [
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": "👍🏻 운영 배포 완료 👍🏻",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "🚀 *배포 버전:*\n${{ inputs.release-ver }}"
}
]
},
{
"type": "divider"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

roll-back-on-fail:
environment: prod
strategy:
matrix:
runners: [be-prod-a, be-prod-b]

runs-on: [self-hosted, '${{ matrix.runners }}']
needs: deploy
if: failure()

defaults:
run:
working-directory: backend
steps:
- name: Extract secrets as .env file
run: |
cat <<EOF > .env
# Docker Hub info from Github Secrets
DOCKER_REPO_NAME=${{ secrets.DOCKER_REPO_NAME }}
DOCKER_IMAGE_VERSION_TAG=${{ inputs.rollback-ver }}
# DB Configuration secrets info from Github Secrets
DB_PORT=${{ secrets.DB_PORT }}
DB_IP_ADDRESS=${{ secrets.DB_IP_ADDRESS }}
READ_DB_URL=${{ secrets.READ_DB_URL }}
WRITE_DB_URL=${{ secrets.WRITE_DB_URL }}
DB_USER=${{ secrets.DB_USER }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
DDL_AUTO=${{ secrets.DDL_AUTO }}
# DB server configuration secrets info from Github Secrets
APP_IP_ADDRESS=${{ secrets.APP_IP_ADDRESS }}
BLUE_SERVER_BINDING_PORT=${{ secrets.BLUE_SERVER_BINDING_PORT }}
GREEN_SERVER_BINDING_PORT=${{ secrets.GREEN_SERVER_BINDING_PORT }}
BLUE_SERVER_PORT=${{ secrets.BLUE_SERVER_PORT }}
GREEN_SERVER_PORT=${{ secrets.GREEN_SERVER_PORT }}

# Monitoring configuration server info from Github secrets
MONITORING_INSTANCE_ADDR_LOKI_PORT=${{ secrets.MONITORING_INSTANCE_ADDR_LOKI_PORT }}
BLUE_MONITORING_BINDING_PORT=${{ secrets.BLUE_MONITORING_BINDING_PORT }}
GREEN_MONITORING_BINDING_PORT=${{ secrets.GREEN_MONITORING_BINDING_PORT }}
MONITORING_BASE_PATH=${{ secrets.MONITORING_BASE_PATH }}
MONITORING_PROFILE=${{ secrets.MONITORING_PROFILE }}

# Apply configuration server info from Github secrets
APPLY_POST_BASE_URL=${{ secrets.APPLY_POST_BASE_URL }}

# Email Auth info
EMAIL_USERNAME=${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}

# Security settings
JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}
JWT_TOKEN_EXPIRE_CYCLE=${{ secrets.JWT_TOKEN_EXPIRE_CYCLE }}
ACCESS_TOKEN_EXPIRE_CYCLE=${{ secrets.ACCESS_TOKEN_EXPIRE_CYCLE }}
REFRESH_TOKEN_EXPIRE_CYCLE=${{ secrets.REFRESH_TOKEN_EXPIRE_CYCLE }}
JWT_SIGN_ALGORITHM=${{ secrets.JWT_SIGN_ALGORITHM }}

# Cookie settings
COOKIE_ACCESS_TOKEN_KEY=${{ secrets.COOKIE_ACCESS_TOKEN_KEY }}
COOKIE_REFRESH_TOKEN_KEY=${{ secrets.COOKIE_REFRESH_TOKEN_KEY }}
COOKIE_HTTP_ONLY=${{ secrets.COOKIE_HTTP_ONLY }}
COOKIE_SECURE=${{ secrets.COOKIE_SECURE }}
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN }}
COOKIE_PATH=${{ secrets.COOKIE_PATH }}
COOKIE_SAME_SITE=${{ secrets.COOKIE_SAME_SITE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
EOF

- name: Run zero down time Deploy Script
run: |
chmod +x ../deploy.sh
../deploy.sh
- name: Run server status check script with timeout
run: ../check_server_status_with_timeout.sh
- name: 배포시작 알림
uses: slackapi/[email protected]
with:
channel-id: C07S8K0PHTQ
payload: |
{
"blocks": [
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ 운영 배포 실패 및 롤백 ❌",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "🚀 *롤백 버전:*\n${{ inputs.rollback-ver }}"
}
]
},
{
"type": "divider"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
10 changes: 9 additions & 1 deletion .github/workflows/be-cd_test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,24 @@ jobs:
# Security settings
JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}
JWT_TOKEN_EXPIRE_CYCLE=${{ secrets.JWT_TOKEN_EXPIRE_CYCLE }}
ACCESS_TOKEN_EXPIRE_CYCLE=${{ secrets.ACCESS_TOKEN_EXPIRE_CYCLE }}
REFRESH_TOKEN_EXPIRE_CYCLE=${{ secrets.REFRESH_TOKEN_EXPIRE_CYCLE }}
JWT_SIGN_ALGORITHM=${{ secrets.JWT_SIGN_ALGORITHM }}
# Cookie settings
COOKIE_ACCESS_TOKEN_KEY=${{ secrets.COOKIE_ACCESS_TOKEN_KEY }}
COOKIE_REFRESH_TOKEN_KEY=${{ secrets.COOKIE_REFRESH_TOKEN_KEY }}
COOKIE_HTTP_ONLY=${{ secrets.COOKIE_HTTP_ONLY }}
COOKIE_SECURE=${{ secrets.COOKIE_SECURE }}
COOKIE_DOMAIN=${{ secrets.COOKIE_DOMAIN }}
COOKIE_PATH=${{ secrets.COOKIE_PATH }}
COOKIE_SAME_SITE=${{ secrets.COOKIE_SAME_SITE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
COOKIE_MAX_AGE=${{ secrets.COOKIE_MAX_AGE }}
# Redis
REDIS_PORT=${{ secrets.REDIS_PORT }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
EOF
- name: Stop and remove existing containers
Expand Down
Loading

0 comments on commit 9604c44

Please sign in to comment.