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 ec36ebb commit 615aaf0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
envs: GITHUB_SHA, DOCKERHUB_USERNAME
script: |
# 현재 활성화된 Nginx 설정 파일 확인
CURRENT_CONF=$(sudo readlink /etc/nginx/nginx.conf)
CURRENT_CONF=$(sudo readlink /etc/nginx/active.conf)
if [[ "$CURRENT_CONF" == *"nginx.blue.conf" ]]; then
NEW_CONF="/etc/nginx/nginx.green.conf"
OLD_CONTAINER="blue-container"
Expand All @@ -68,18 +68,20 @@ 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 ln -sf $NEW_CONF /etc/nginx/active.conf
sudo systemctl reload nginx
# 이전 컨테이너 중지 및 제거
sudo docker stop $OLD_CONTAINER
sudo docker rm $OLD_CONTAINER
if sudo docker ps -a --format '{{.Names}}' | grep -Eq "^${OLD_CONTAINER}\$"; then
sudo docker stop $OLD_CONTAINER
sudo docker rm $OLD_CONTAINER
fi
# 사용하지 않는 Docker 이미지 정리
sudo docker image prune -f

0 comments on commit 615aaf0

Please sign in to comment.