Updating docker and switching to env files

This commit is contained in:
2025-04-13 12:30:49 -04:00
parent 5c4cdb8a72
commit 9a6a190f36
2 changed files with 15 additions and 13 deletions

View File

@@ -34,9 +34,8 @@ RUN --mount=type=ssh mkdir src && \
# Copy the actual source code # Copy the actual source code
COPY src ./src COPY src ./src
# If you have other directories like `templates` or `static`, copy them too # If you have other directories like `templates` or `static`, copy them too
# COPY templates ./templates
# COPY static ./static
COPY .env ./.env COPY .env ./.env
COPY auth_db.env ./auth_db.env
COPY migrations ./migrations COPY migrations ./migrations
# << --- SSH MOUNT ADDED HERE --- >> # << --- 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 # 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 # 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/.env .
COPY --from=builder /usr/src/app/auth_db.env .
COPY --from=builder /usr/src/app/migrations ./migrations 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 the port your Axum app listens on (e.g., 3000 or 8000)
EXPOSE 3000 EXPOSE 3000

View File

@@ -2,36 +2,40 @@ version: '3.8' # Use a recent version
services: services:
# Your Rust Application Service # Your Rust Application Service
app: auth_api:
build: . # Tells docker-compose to build the Dockerfile in the current directory build: . # Tells docker-compose to build the Dockerfile in the current directory
container_name: icarus_auth # Optional: Give the container a specific name container_name: icarus_auth # Optional: Give the container a specific name
ports: ports:
# Map host port 8000 to container port 3000 (adjust as needed) # Map host port 8000 to container port 3000 (adjust as needed)
# Format: "HOST_PORT:CONTAINER_PORT" # Format: "HOST_PORT:CONTAINER_PORT"
- "8000:3000" - "8000:3000"
environment: # environment:
# Pass environment variables to your Rust application # Pass environment variables to your Rust application
# RUST_LOG: info # Example: Set log level # RUST_LOG: info # Example: Set log level
# IMPORTANT: Configure DATABASE_URL to connect to the 'db' service # IMPORTANT: Configure DATABASE_URL to connect to the 'db' service
# The hostname 'db' matches the service name defined below. # 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 # Add any other environment variables your app needs
# APP_HOST: 0.0.0.0 # APP_HOST: 0.0.0.0
# APP_PORT: 3000 # APP_PORT: 3000
env_file:
- .env
depends_on: depends_on:
db: auth_db:
condition: service_healthy # Wait for the DB to be healthy before starting the app condition: service_healthy # Wait for the DB to be healthy before starting the app
restart: unless-stopped # Optional: Restart policy restart: unless-stopped # Optional: Restart policy
# PostgreSQL Database Service # PostgreSQL Database Service
db: auth_db:
image: postgres:17.4-alpine # Use an official Postgres image (Alpine variant is smaller) 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 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 # These MUST match the user, password, and database name in the DATABASE_URL above
POSTGRES_USER: icarus_op # POSTGRES_USER: icarus_op
POSTGRES_PASSWORD: password # POSTGRES_PASSWORD: password
POSTGRES_DB: icarus_auth # POSTGRES_DB: icarus_auth
env_file:
- auth_db.env
volumes: volumes:
# Persist database data using a named volume # Persist database data using a named volume
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data