From 30b6a3d803ba83d4f832f05a4f14cc03642ab822 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Aug 2026 03:56:55 +0000 Subject: [PATCH] Fix Docker deployment: Update settings.py defaults and Dockerfile for proper environment variable handling - Updated settings.py to use Docker service names as defaults (postgres_platform, postgres_mtgdata, postgres_mirror, redis) - Added MTG_MIRROR_DATABASE_URL setting - Dockerfile copies .env file into container for pydantic-settings - Entry point script handles dependency checking and migrations before app startup --- backend/Dockerfile | 3 ++- backend/app/core/settings.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index a32e485..54a5631 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -54,7 +54,8 @@ COPY --chown=appuser:appuser alembic/ ./alembic/ COPY --chown=appuser:appuser scripts/ ./scripts/ RUN chmod +x /app/scripts/*.py /app/scripts/docker-entrypoint.sh -# Copy environment example +# Copy environment files +COPY --chown=appuser:appuser .env ./.env COPY --chown=appuser:appuser .env.example ./.env.example COPY --chown=appuser:appuser pyproject.toml ./ diff --git a/backend/app/core/settings.py b/backend/app/core/settings.py index 67c71b3..ce6a5ed 100644 --- a/backend/app/core/settings.py +++ b/backend/app/core/settings.py @@ -19,13 +19,16 @@ class Settings(BaseSettings): JWT_SECRET_KEY: str = "change-me-in-production" # Database - Primary (mtgonline app) - DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/mtgo_platform" + DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@postgres_platform:5432/mtgo_platform" # Database - Secondary (mtgjson data) - MTG_DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/mtg_data" + MTG_DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@postgres_mtgdata:5432/mtgdata" + + # Database - Mirror + MTG_MIRROR_DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@postgres_mirror:5432/mtgo_mirror" # Redis - REDIS_URL: str = "redis://localhost:6379/0" + REDIS_URL: str = "redis://redis:6379/0" # JWT Configuration JWT_ALGORITHM: str = "HS256"