From d05141075e5cf438c5c9647a61da603258a9a06a Mon Sep 17 00:00:00 2001 From: Darryl Nixon Date: Fri, 2 Jun 2023 19:46:04 -0700 Subject: [PATCH] Add alembic migration support to Docker* --- Dockerfile | 2 +- docker-compose.yml | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index adb1326..3e82182 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,4 +34,4 @@ EXPOSE ${ENV_GHOSTFORGE_INTERNAL_WEB_PORT} # TODO: Replace with ghostforge_serve when it works. # This currently just keeps the container running for development. -CMD ["sh", "-c", "uvicorn ghostforge.serve:gf --host 0.0.0.0 --port $GHOSTFORGE_INTERNAL_WEB_PORT"] +CMD ["sh", "-c", "alembic upgrade head && uvicorn ghostforge.serve:gf --host 0.0.0.0 --port $GHOSTFORGE_INTERNAL_WEB_PORT"] diff --git a/docker-compose.yml b/docker-compose.yml index 5836bbc..a97c9fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,11 @@ services: image: postgres:15.3 container_name: ghostforge-db restart: unless-stopped + healthcheck: + test: [ "CMD-SHELL", "pg_isready" ] + interval: 10s + timeout: 5s + retries: 5 volumes: - ghostforge-db-data:/var/lib/postgresql/data ports: [ "5432:5432" ] @@ -25,7 +30,9 @@ services: image: ghostforge:latest container_name: ghostforge restart: unless-stopped - depends_on: [ ghostforge-db ] + depends_on: + ghostforge-db: + condition: service_healthy env_file: [ .env ] volumes: - ./migrations/versions:/ghostforge/migrations/versions