# Docker Compose configuration for EDH Stats Tracker services: # PostgreSQL database service postgres: image: postgres:16-alpine container_name: edh-stats-postgres environment: - POSTGRES_USER=${DB_USER:-postgres} - POSTGRES_PASSWORD=${DB_PASSWORD:-edh_password} - POSTGRES_DB=${DB_NAME:-edh_stats} volumes: - ./postgres_data:/var/lib/postgresql/data - ./backend/init-db:/docker-entrypoint-initdb.d - ./scripts:/scripts:ro - ./backups:/backups healthcheck: test: [ 'CMD-SHELL', 'PGPASSWORD=${DB_PASSWORD:-edh_password} pg_isready -U postgres -h localhost' ] interval: 10s timeout: 5s retries: 5 networks: - edh-stats-network restart: unless-stopped # Database migration service - runs once on startup db-migrate: build: context: ./backend dockerfile: Dockerfile target: production container_name: edh-stats-db-migrate depends_on: postgres: condition: service_healthy environment: - NODE_ENV=${NODE_ENV:-development} - DB_HOST=${DB_HOST:-postgres} - DB_NAME=${DB_NAME:-edh_stats} - DB_USER=${DB_USER:-postgres} - DB_PASSWORD=${DB_PASSWORD:-edh_password} # Set DB_SEED=true to automatically seed database with sample data after migrations - DB_SEED=${DB_SEED:-false} command: node src/database/migrate.js migrate networks: - edh-stats-network restart: 'no' # Backend API service backend: build: context: ./backend dockerfile: Dockerfile target: production container_name: edh-stats-backend ports: - '3002:3000' depends_on: db-migrate: condition: service_completed_successfully environment: - NODE_ENV=${NODE_ENV:-development} - DB_HOST=${DB_HOST:-postgres} - DB_NAME=${DB_NAME:-edh_stats} - DB_USER=${DB_USER:-postgres} - DB_PASSWORD=${DB_PASSWORD:-edh_password} - JWT_SECRET=${JWT_SECRET:-dev-jwt-secret-key-change-in-production} - CORS_ORIGIN=${CORS_ORIGIN:-http://localhost} - LOG_LEVEL=${LOG_LEVEL:-info} - ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} volumes: - ./backend/src:/app/src restart: unless-stopped healthcheck: test: [ 'CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/api/health' ] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - edh-stats-network # Frontend web server frontend: image: nginx:alpine container_name: edh-stats-frontend ports: - '8081:80' depends_on: - backend volumes: - ./frontend/nginx.conf:/etc/nginx/nginx.conf:ro - ./frontend/public:/usr/share/nginx/html:ro restart: unless-stopped healthcheck: test: - CMD - curl - http://localhost:80/health interval: 10s timeout: 5s retries: 5 networks: - edh-stats-network volumes: postgres_data: driver: local networks: edh-stats-network: driver: bridge