Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
with:
context: .
file: Docker/Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/realmatch-backend:prod
Expand All @@ -48,16 +49,15 @@ jobs:
key: ${{ secrets.PROD_SERVER_SSH_KEY }}
script: |
cd /home/ubuntu/realmatch
git pull origin main

docker compose pull
docker compose up -d
docker-compose pull
docker-compose up -d

echo "Waiting for app to start..."
sleep 10
if ! docker compose ps | grep "Up"; then

if ! docker-compose ps | grep "Up"; then
echo "❌ Container is not running"
docker compose logs
docker-compose logs
exit 1
fi
fi
7 changes: 3 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ services:
- "6379:6379"

app:
build:
context: .
dockerfile: Docker/Dockerfile
image: ${DOCKERHUB_USERNAME}/realmatch-backend:prod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Docker 이미지 태그로 prod를 사용하고 계십니다. 이 방식은 새로운 이미지를 배포할 때마다 같은 태그를 덮어쓰게 되어, 특정 버전으로 롤백하기 어렵게 만들 수 있습니다.

Git commit hash나 시맨틱 버전(예: v1.2.3)과 같이 각 빌드를 고유하게 식별할 수 있는 태그를 사용하는 것을 권장합니다. 이렇게 하면 배포된 버전을 명확하게 추적하고, 문제 발생 시 안정적인 이전 버전으로 쉽게 롤백할 수 있습니다.

예시:

image: ${DOCKERHUB_USERNAME}/realmatch-backend:${IMAGE_TAG:-prod}

CI/CD 파이프라인에서 IMAGE_TAG 환경 변수를 설정하여 동적으로 태그를 주입할 수 있습니다.

    image: ${DOCKERHUB_USERNAME}/realmatch-backend:${IMAGE_TAG:-prod}

container_name: spring_app
restart: always
ports:
- "6000:6000"
- "8080:6000"
depends_on:
- db
- redis
Expand Down
Loading