diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 94c52a1..fa6d959 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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: @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 391818f..438a563 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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