Skip to content

Commit

Permalink
feat: Added docker-compose.yml. Modified deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gyehyun-bak committed Oct 24, 2024
1 parent 57d618c commit 39462a4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
key: ${{ secrets.EC2_PRIVATE_KEY }}
script_stop: true
script: |
docker stop cano-server || true
docker rm cano-server || true
docker pull ${{ steps.login-ecr.outputs.registry }}/cano-server:latest
docker run -d --name cano-server -p 8080:8080 ${{ steps.login-ecr.outputs.registry }}/cano-server:latest
docker-compose down || true # 기존 컨테이너 중지 및 제거
docker-compose pull # ECR에서 최신 이미지를 가져오기
docker-compose up -d # 새로운 컨테이너 실행
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
db:
image: mysql
container_name: cano-mysql
environment:
MYSQL_ROOT_PASSWORD: password123
MYSQL_DATABASE: cano
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
networks:
- cano-network
healthcheck:
test: [ "CMD", "mysqladmin", "ping" ] # MySQL이 healthy 한 지 판단할 수 있는 명령어
interval: 5s # 5초 간격으로 체크
retries: 10 # 10번까지 재시도

app:
image: cano-server:latest
container_name: cano-server
depends_on:
- db:
condition: service-healthy
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/cano
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: password123
networks:
- cano-network

networks:
cano-network:
driver: bridge

volumes:
db_data:

0 comments on commit 39462a4

Please sign in to comment.