From 39bdb735f5a156f6364cd70fc3b4be9e61dfbf57 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Wed, 9 Apr 2025 22:39:53 +0200 Subject: [PATCH] Refactor Docker setup and migrate to PostgreSQL Streamlined Dockerfiles with clearer ENV variables and build args. Switched backend database from MySQL to PostgreSQL, updated configurations accordingly, and added robust Docker Compose services for better orchestration, including health checks and persistent storage. --- docker-compose.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 98d724d..0a2a793 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: volumes: - ./backend:/app/backend # Map backend directory to /app/backend - ./app:/app/app # Map app directory to /app/app - - ./config_dev.json:/app/backend/config_dev.json # Explicitly map config_dev.json + - ./config_${ENVIRONMENT}.json:/app/backend/config_${ENVIRONMENT}.json # Explicitly map config_dev.json - ./backend/ssl:/app/backend/ssl # clearly mount SSL files explicitly into Docker working_dir: /app/backend # Set working directory to backend/ command: python main.py # Command to run main.py @@ -23,11 +23,11 @@ services: timeout: 5s retries: 5 environment: # ⬅️ Provide DB info to your backend - ENVIRONMENT: dev - DB_USERNAME: dev_user - DB_PASSWORD: dev_password + ENVIRONMENT: ${ENVIRONMENT} + DB_USERNAME: ${DB_USERNAME} + DB_PASSWORD: ${DB_PASSWORD} DB_HOST: postgres - DB_NAME: aare_dev_db + DB_NAME: ${DB_NAME} postgres: # ⬅️ New service (our PostgreSQL database) image: postgres:16 @@ -49,7 +49,7 @@ services: context: ./frontend dockerfile: Dockerfile args: - - VITE_OPENAPI_BASE_DEV=${VITE_OPENAPI_BASE_DEV} + - VITE_OPENAPI_BASE=${VITE_OPENAPI_BASE} - VITE_SSL_KEY_PATH=${VITE_SSL_KEY_PATH} - VITE_SSL_CERT_PATH=${VITE_SSL_CERT_PATH} - NODE_ENV=${NODE_ENV} @@ -59,7 +59,7 @@ services: - ./frontend:/app - /app/node_modules # ⬅️ explicit exclusion! ensures Docker-provided modules retain explicitly. - ./backend/ssl:/app/backend/ssl - - ./backend/config_dev.json:/app/backend/config_${ENVIRONMENT}.json # Dynamically maps config based on environment + - ./backend/config_${ENVIRONMENT}.json:/app/backend/config_${ENVIRONMENT}.json # Dynamically maps config based on environment command: sh -c "npm run dev & ENVIRONMENT=dev npm run watch:openapi" @@ -68,7 +68,7 @@ services: context: ./logistics dockerfile: Dockerfile args: # 👈 explicitly pass build args from .env - - VITE_OPENAPI_BASE_DEV=${VITE_OPENAPI_BASE_DEV} + - VITE_OPENAPI_BASE=${VITE_OPENAPI_BASE} - VITE_SSL_KEY_PATH=${VITE_SSL_KEY_PATH} - VITE_SSL_CERT_PATH=${VITE_SSL_CERT_PATH} - NODE_ENV=${NODE_ENV} @@ -80,7 +80,7 @@ services: - ./logistics/src:/app/src # explicitly for active dev (hot reload) - ./backend/ssl:/app/backend/ssl # clearly mount SSL files explicitly into Docker environment: - - VITE_OPENAPI_BASE_DEV=${VITE_OPENAPI_BASE_DEV} + - VITE_OPENAPI_BASE=${VITE_OPENAPI_BASE} volumes: # ⬅️ Persistent storage for PostgreSQL data