# Docker Compose configuration for EDH Stats Tracker # DEVELOPMENT ENVIRONMENT with hot reload # For production deployment, use docker-compose.prod.deployed.yml (generated by deploy.sh or GitHub Actions) 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 - ./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:5173} - LOG_LEVEL=${LOG_LEVEL:-info} - ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} - MAX_USERS=${MAX_USERS:-} 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 (SvelteKit) - Development Mode with Hot Reload frontend: build: context: ./frontend dockerfile: Dockerfile.dev container_name: edh-stats-frontend ports: - '5173:5173' # Vite dev server depends_on: - backend environment: - NODE_ENV=development - DOCKER=true - VITE_API_URL=http://localhost:3002 volumes: - ./frontend/src:/app/src - ./frontend/static:/app/static - ./frontend/svelte.config.js:/app/svelte.config.js - ./frontend/vite.config.js:/app/vite.config.js - ./frontend/tailwind.config.js:/app/tailwind.config.js - ./frontend/postcss.config.js:/app/postcss.config.js # Exclude node_modules and build artifacts from volume mount - /app/node_modules - /app/.svelte-kit command: npm run dev -- --host 0.0.0.0 restart: unless-stopped networks: - edh-stats-network volumes: postgres_data: driver: local networks: edh-stats-network: driver: bridge