From 9a6a190f36da653e72598bc3d26e69acd2c72967 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sun, 13 Apr 2025 12:30:49 -0400 Subject: [PATCH] Updating docker and switching to env files --- Dockerfile | 6 ++---- docker-compose.yaml | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48e6b75..de67ef8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,9 +34,8 @@ RUN --mount=type=ssh mkdir src && \ # Copy the actual source code COPY src ./src # If you have other directories like `templates` or `static`, copy them too -# COPY templates ./templates -# COPY static ./static COPY .env ./.env +COPY auth_db.env ./auth_db.env COPY migrations ./migrations # << --- SSH MOUNT ADDED HERE --- >> @@ -63,9 +62,8 @@ COPY --from=builder /usr/src/app/target/release/icarus_auth . # Copy other necessary files like .env (if used for runtime config) or static assets # It's generally better to configure via environment variables in Docker though COPY --from=builder /usr/src/app/.env . +COPY --from=builder /usr/src/app/auth_db.env . COPY --from=builder /usr/src/app/migrations ./migrations -# COPY --from=builder /usr/src/app/templates ./templates -# COPY --from=builder /usr/src/app/static ./static # Expose the port your Axum app listens on (e.g., 3000 or 8000) EXPOSE 3000 diff --git a/docker-compose.yaml b/docker-compose.yaml index 38c1b41..8790d65 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,36 +2,40 @@ version: '3.8' # Use a recent version services: # Your Rust Application Service - app: + auth_api: build: . # Tells docker-compose to build the Dockerfile in the current directory container_name: icarus_auth # Optional: Give the container a specific name ports: # Map host port 8000 to container port 3000 (adjust as needed) # Format: "HOST_PORT:CONTAINER_PORT" - "8000:3000" - environment: + # environment: # Pass environment variables to your Rust application # RUST_LOG: info # Example: Set log level # IMPORTANT: Configure DATABASE_URL to connect to the 'db' service # The hostname 'db' matches the service name defined below. - DATABASE_URL: postgresql://icarus_op:password@db:5432/icarus_auth + # DATABASE_URL: postgresql://icarus_op:password@db:5432/icarus_auth # Add any other environment variables your app needs # APP_HOST: 0.0.0.0 # APP_PORT: 3000 + env_file: + - .env depends_on: - db: + auth_db: condition: service_healthy # Wait for the DB to be healthy before starting the app restart: unless-stopped # Optional: Restart policy # PostgreSQL Database Service - db: + auth_db: image: postgres:17.4-alpine # Use an official Postgres image (Alpine variant is smaller) container_name: icarus_auth_db # Optional: Give the container a specific name - environment: + # environment: # These MUST match the user, password, and database name in the DATABASE_URL above - POSTGRES_USER: icarus_op - POSTGRES_PASSWORD: password - POSTGRES_DB: icarus_auth + # POSTGRES_USER: icarus_op + # POSTGRES_PASSWORD: password + # POSTGRES_DB: icarus_auth + env_file: + - auth_db.env volumes: # Persist database data using a named volume - postgres_data:/var/lib/postgresql/data