Skip to content

Commit

Permalink
feat: nginx blue green 무중단 배포
Browse files Browse the repository at this point in the history
  • Loading branch information
sjy2335 committed Nov 12, 2024
1 parent 49e86c0 commit fc86150
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/deploy-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,23 @@ jobs:
touch .env
echo "${{ secrets.env }}" > .env
docker pull ghcr.io/${{ github.repository_owner }}/${{ inputs.service }}/${{inputs.path}}:latest
if docker-compose up -d; then
echo "Deployment successful"
else
echo "Deployment failed, rolling back"
docker-compose down
docker pull ghcr.io/${{ github.repository_owner }}/${{ inputs.service }}/${{inputs.path}}:previous-tag
docker-compose up -d
exit 1
fi
# Blue 인스턴스를 새 버전으로 준비
docker-compose up -d --no-deps console-server-blue
# Blue 인스턴스 헬스 체크
for i in {1..30}; do
if curl -s http://localhost | grep -q "Hello World!"; then
echo "Blue container is ready"
break
fi
echo "Waiting for Blue container to be ready..."
sleep 1
done
# Nginx 리로드로 트래픽 전환
docker-compose exec nginx nginx -s reload
# 기존 Green 인스턴스 종료
docker-compose up -d --no-deps console-server-green
echo "Deployment completed successfully"

0 comments on commit fc86150

Please sign in to comment.