diff --git a/.env.example b/.env.example index 35141536..d8e29e02 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,7 @@ # PostgreSQL DB_PORT=5432 -DB_HOST=postgres +DB_HOST=db DB_USER= DB_PASSWORD= DB_NAME=report_db diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 98303563..a83296c7 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -43,7 +43,7 @@ jobs: - name: Restart containers run: | cd "$DEPLOY_DIR" - docker compose up -d + docker compose up -d --remove-orphans # backend/frontend는 항상 새로 기동: DB 교체 시 스키마 재동기화, # nginx의 낡은 upstream IP 캐시 방지 docker compose up -d --no-deps --force-recreate backend frontend diff --git a/docker-compose.yml b/docker-compose.yml index b6b3c5ef..944c422c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - postgres: + db: image: postgres:16-alpine container_name: report-db restart: always @@ -14,7 +14,7 @@ services: networks: - app-network healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-report_db}"] + test: [ "CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-report_db}" ] interval: 5s timeout: 5s retries: 20 @@ -27,7 +27,7 @@ services: expose: - "3000" environment: - - DB_HOST=${DB_HOST:-postgres} + - DB_HOST=${DB_HOST:-db} - DB_PORT=${DB_PORT:-5432} - DB_USER=${DB_USER:-postgres} - DB_PASSWORD=${DB_PASSWORD:?DB_PASSWORD가 .env에 설정되어야 합니다} @@ -38,7 +38,7 @@ services: - ADMIN_PASS=${ADMIN_PASS:?ADMIN_PASS가 .env에 설정되어야 합니다} - JEMINI_KEY=${JEMINI_KEY} depends_on: - postgres: + db: condition: service_healthy volumes: - ./backend/img:/app/img @@ -63,4 +63,4 @@ networks: driver: bridge # npm(Nginx Proxy Manager)이 컨테이너 이름으로 라우팅하는 공용 네트워크 proxy: - external: true \ No newline at end of file + external: true