Skip to content

Commit

Permalink
Test: 블루-그린 무중단 배포 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
tioon committed Jun 30, 2024
1 parent 15bab16 commit ec36ebb
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ jobs:

- name: EC2 서버에 배포
uses: appleboy/ssh-action@master
envs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
host: ${{ secrets.PROD_SERVER_HOST }}
username: ${{ secrets.PROD_SERVER_USERNAME }}
key: ${{ secrets.PROD_SERVER_PEM_KEY }}
host: ${{ secrets.STG_SERVER_HOST }}
username: ${{ secrets.STG_SERVER_USERNAME }}
key: ${{ secrets.STG_SERVER_PEM_KEY }}
envs: GITHUB_SHA, DOCKERHUB_USERNAME
script: |
# 현재 활성화된 Nginx 설정 파일 확인
CURRENT_CONF=$(sudo readlink /etc/nginx/nginx.conf)
Expand All @@ -70,19 +68,18 @@ jobs:
NEW_CONTAINER="blue-container"
NEW_PORT=8000
fi
# 새 Docker 이미지 가져오기 및 새로운 컨테이너 실행
sudo docker pull $DOCKERHUB_USERNAME/qtudy-server:latest
sudo docker run -d -p $NEW_PORT:8080 --name $NEW_CONTAINER $DOCKERHUB_USERNAME/qtudy-server:latest
# Nginx 설정 파일 교체 및 재시작
sudo ln -sf $NEW_CONF /etc/nginx/nginx.conf
sudo systemctl reload nginx
# 이전 컨테이너 중지 및 제거
sudo docker stop $OLD_CONTAINER
sudo docker rm $OLD_CONTAINER
# 사용하지 않는 Docker 이미지 정리
sudo docker image prune -f
sudo docker image prune -f

0 comments on commit ec36ebb

Please sign in to comment.