Skip to content

Commit

Permalink
chore: 도커 컴포즈를 사용하여 CD 실행
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghye218 committed Oct 11, 2024
1 parent 18c187a commit 8e10993
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/backend-prod-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Backend Prod CD
on:
workflow_dispatch:
push:
branches: ['main']
branches: [ 'main' ]

jobs:
detect-changes:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
runner: [ prod-a, prod-b ]
# fail-fast 옵션을 명시적으로 설정
fail-fast: true
runs-on: [self-hosted, linux, ARM64, ${{ matrix.runner }}]
runs-on: [ self-hosted, linux, ARM64, ${ { matrix.runner } } ]
defaults:
run:
shell: bash
Expand All @@ -109,20 +109,10 @@ jobs:
- name: docker pull
run: docker pull ${{ secrets.DOCKERHUB_USERNAME }}/momo-api-prod

# 2. 기존 컨테이너 중지
- name: docker stop container
run: docker stop $(docker ps -q) 2>/dev/null || true

# 3. 도커 컨테이너 실행
- name: docker run new container
run: >-
docker run --name momo-api-prod
--rm -d -p 8080:8080
--volume=$HOME/security:/momo/security:ro
--volume=$HOME/logs:/momo/logs
--env SPRING_PROFILE=prod
${{ secrets.DOCKERHUB_USERNAME }}/momo-api-prod
# 4. 미사용 이미지를 정리
# 2. 실행 컨테이너 중 app 서비스만 재시작
- name: Restart app service
run: docker compose -f $HOME/security/docker-compose-prod.yml restart app --no-deps

# 3. 미사용 이미지를 정리
- name: delete old docker image
run: docker system prune -f

0 comments on commit 8e10993

Please sign in to comment.