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
20 changes: 13 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ permissions:
contents: read

env:
IMAGE: ${{ secrets.DOCKER_USERNAME }}/kkumteul-backend
BACKEND_IMAGE: ${{ secrets.DOCKER_USERNAME }}/kkumteul-backend
FASTAPI_IMAGE: ${{ secrets.DOCKER_USERNAME }}/kkumteul-ai

jobs:
deploy:
Expand Down Expand Up @@ -38,16 +39,21 @@ jobs:
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
port: 22
envs: IMAGE
envs: BACKEND_IMAGE,FASTAPI_IMAGE
script: |
cd /home/${{ secrets.SERVER_USER }}/app
echo "BACKEND_IMAGE=${IMAGE}:latest" > .env
echo "BACKEND_IMAGE=${BACKEND_IMAGE}:latest" > .env
echo "FASTAPI_IMAGE=${FASTAPI_IMAGE}:latest" >> .env

echo "[1/3] Pull latest image..."
docker pull ${IMAGE}:latest
echo "[1/4] Pull latest images..."
docker pull ${BACKEND_IMAGE}:latest
docker pull ${FASTAPI_IMAGE}:latest

echo "[2/3] Restart with docker compose..."
echo "[2/4] Restart with docker compose..."
docker compose up -d --remove-orphans

echo "[3/3] Cleanup unused images..."
echo "[3/4] Force-recreate nginx for config changes..."
docker compose up -d --force-recreate nginx

echo "[4/4] Cleanup unused images..."
docker image prune -f
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ services:
- ./application.properties:/app/config/application.properties:ro
expose:
- "8080"
depends_on:
- fastapi
networks:
- kkumteul

fastapi:
image: ${FASTAPI_IMAGE}
container_name: fastapi
restart: always
env_file:
- .env.fastapi
expose:
- "8000"
networks:
- kkumteul

Expand Down
Loading