Skip to content

Commit

Permalink
fix: DEPLOY 스크립트 (#98)
Browse files Browse the repository at this point in the history
fix: DEPLOY 스크립트 (#98)
  • Loading branch information
fru1tworld authored Nov 12, 2024
2 parents 6166b43 + 24ede1b commit 6319504
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions .github/workflows/BACKEND_DEPLOY.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,15 @@ jobs:
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}

- name: 도커 이미지 빌드 및 푸시 (Blue)
id: docker-build-blue
- name: 도커 이미지 빌드 및 푸시
id: docker-build
uses: docker/build-push-action@v3
with:
context: .
file: ./packages/backend/Dockerfile.blue
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:blue-latest
tags: ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:latest

- name: 도커 이미지 빌드 및 푸시 (Green)
id: docker-build-green
uses: docker/build-push-action@v3
with:
context: .
file: ./packages/backend/Dockerfile.green
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:green-latest

pull_from_registry:
runs-on: ubuntu-latest
Expand All @@ -56,25 +48,9 @@ jobs:
run: |
docker login -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }} ${{ secrets.CONTAINER_REGISTRY_URL }}
- name: 현재 실행 중인 Blue/Green 확인
id: check-current
run: |
if docker ps --filter "name=backend_green" --format '{{.Names}}' | grep -w backend_green; then
echo "current=green" | tee -a $GITHUB_ENV
else
echo "current=blue" | tee -a $GITHUB_ENV
fi
- name: 컨테이너 업데이트 및 Blue/Green 전환
- name: 컨테이너 업데이트
run: |
if [ "$current" = "green" ]; then
docker stop backend_green || true
docker rm backend_green || true
docker pull ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:blue-latest
docker run -d --name backend_blue --network product_network -p 3000:3000 ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:blue-latest
else
docker stop backend_blue || true
docker rm backend_blue || true
docker pull ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:green-latest
docker run -d --name backend_blue --network product_network -p 3001:3000 ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:blue-latest
fi
docker stop backend
docker rm backend
docker pull ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:latest
docker run -d --name backend_blue --network product_network -p 3000:3000 ${{ secrets.CONTAINER_REGISTRY_URL }}/backend:latest

0 comments on commit 6319504

Please sign in to comment.