59 lines
2.2 KiB
YAML
59 lines
2.2 KiB
YAML
# docker-compose.yml
|
|
version: '3.8'
|
|
|
|
services:
|
|
db:
|
|
image: mariadb:10.11 # Use a specific stable version
|
|
container_name: lms_mariadb
|
|
restart: unless-stopped
|
|
environment:
|
|
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-supersecretroot} # Use default if not set in host .env
|
|
MARIADB_DATABASE: ${MARIADB_DATABASE:-lms_db}
|
|
MARIADB_USER: ${MARIADB_USER:-lms_user}
|
|
MARIADB_PASSWORD: ${MARIADB_PASSWORD:-lms_password}
|
|
volumes:
|
|
- mariadb_data:/var/lib/mysql # Persist data
|
|
ports:
|
|
# Only expose if you need direct access from host machine, otherwise backend connects via internal network
|
|
# - "3306:3306"
|
|
- "13306:3306" # Expose on 13306 to avoid host conflicts
|
|
networks:
|
|
- lms_network
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${MARIADB_USER:-lms_user}", "-p${MARIADB_PASSWORD:-lms_password}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
backend:
|
|
container_name: lms_backend
|
|
build:
|
|
context: ./lms-backend # Path to the directory containing the Dockerfile
|
|
dockerfile: Dockerfile
|
|
restart: unless-stopped
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy # Wait for DB to be healthy
|
|
environment:
|
|
# Pass necessary environment variables to the backend container
|
|
# Ensure these match the .env file used by the Rust app OR override them here
|
|
DATABASE_URL: mysql://${MARIADB_USER:-lms_user}:${MARIADB_PASSWORD:-lms_password}@db:3306/${MARIADB_DATABASE:-lms_db}
|
|
SERVER_ADDR: 0.0.0.0:8080
|
|
RUST_LOG: ${RUST_LOG:-actix_web=info,lms_backend=info}
|
|
# SECRET_KEY: ${SECRET_KEY:-your_fallback_secret} # If using JWT
|
|
ports:
|
|
- "8080:8080" # Map container port 8080 to host port 8080
|
|
networks:
|
|
- lms_network
|
|
# Optional: Mount local code for development (use with caution, requires rebuilds/restarts)
|
|
# volumes:
|
|
# - ./lms-backend/src:/app/src
|
|
# - ./lms-backend/Cargo.toml:/app/Cargo.toml
|
|
# - ./lms-backend/Cargo.lock:/app/Cargo.lock
|
|
|
|
volumes:
|
|
mariadb_data: # Define the named volume for persistence
|
|
|
|
networks:
|
|
lms_network: # Define the network for services communication
|
|
driver: bridge |