Added Docker file #117

Merged
kdeng00 merged 16 commits from add_docker into v0.2 2025-04-13 14:53:05 -04:00
Showing only changes of commit d0cfcf3499 - Show all commits
+23 -15
View File
@@ -9,20 +9,22 @@ services:
# 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:password@main_db:5432/icarus_db # DATABASE_URL: postgresql://icarus:password@main_db:5432/icarus_db
# 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:
main_db: main_db:
condition: service_healthy condition: service_healthy
networks: networks:
- app-network - main-api-network
restart: unless-stopped # Optional: Restart policy restart: unless-stopped # Optional: Restart policy
# --- Web API auth --- # --- Web API auth ---
@@ -34,17 +36,17 @@ services:
restart: unless-stopped restart: unless-stopped
ports: ports:
- "8001:3000" # Map host port 8000 to container port 8000 (adjust container port based on your app's EXPOSE in Dockerfile) - "8001:3000" # Map host port 8000 to container port 8000 (adjust container port based on your app's EXPOSE in Dockerfile)
environment: # environment:
# Environment variables your API needs, e.g., database connection # Environment variables your API needs, e.g., database connection
DATABASE_URL: postgresql://icarus:password@auth_db:5432/icarus_auth_db # DATABASE_URL: postgresql://icarus:password@auth_db:5432/icarus_auth_db
# Add other necessary environment variables # Add other necessary environment variables
# env_file: env_file:
# - ../icarus_auth/.env - ../icarus_auth/.env
depends_on: depends_on:
auth_db: auth_db:
condition: service_healthy condition: service_healthy
networks: networks:
- app-network - auth-api-network
# Optional: Mount local code for development (live reload) # Optional: Mount local code for development (live reload)
# volumes: # volumes:
# - ./path/to/your/web-api-repo:/app # - ./path/to/your/web-api-repo:/app
@@ -56,9 +58,9 @@ services:
container_name: icarus_db # Optional: Give the container a specific name container_name: icarus_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 POSTGRES_USER: ${POSTGRES_USER:-icarus}
POSTGRES_PASSWORD: password POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: icarus_db POSTGRES_DB: ${POSTGRES_DB:-icarus_db}
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
@@ -74,6 +76,8 @@ services:
retries: 5 retries: 5
start_period: 10s start_period: 10s
restart: always # Optional: Restart policy restart: always # Optional: Restart policy
networks:
- main-api-network
# --- icarus web auth api db # --- icarus web auth api db
auth_db: auth_db:
@@ -81,9 +85,9 @@ services:
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 POSTGRES_USER: ${POSTGRES_USER:-icarus_op}
POSTGRES_PASSWORD: password POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: icarus_auth_db POSTGRES_DB: ${POSTGRES_DB:-icarus_auth_db}
volumes: volumes:
# Persist database data using a named volume # Persist database data using a named volume
- postgres_data_auth:/var/lib/postgresql/data - postgres_data_auth:/var/lib/postgresql/data
@@ -99,6 +103,8 @@ services:
retries: 5 retries: 5
start_period: 10s start_period: 10s
restart: always # Optional: Restart policy restart: always # Optional: Restart policy
networks:
- auth-api-network
# Define the named volume for data persistence # Define the named volume for data persistence
volumes: volumes:
@@ -109,5 +115,7 @@ volumes:
# Define the network (optional, but good practice) # Define the network (optional, but good practice)
networks: networks:
app-network: main-api-network:
driver: bridge
auth-api-network:
driver: bridge driver: bridge