# Example production stack for CaseGambling
# Usage:
#   cp .env.prod.example .env.prod
#   # edit .env.prod (SESSION_SECRET, CLIENT_ORIGIN, ADMIN_USERNAME, ADMIN_PASSWORD, …)
#   docker compose --env-file .env.prod up -d

services:
  casegambling:
    image: foufure/casegambling:latest
    # Or build locally instead of pulling:
    # build: .
    container_name: casegambling
    restart: unless-stopped
    ports:
      - "${HOST_PORT:-3009}:3001"
    env_file:
      - .env.prod
    environment:
      NODE_ENV: production
      PORT: "3001"
      DATABASE_URL: file:/data/prod.db
    # Override image entrypoint so Int→BigInt (etc.) schema pushes can apply.
    # Safe widening; do not use --force-reset (wipes DB).
    command: ["sh", "-c", "npx prisma db push --accept-data-loss && node src/index.js"]
    volumes:
      - casegambling_data:/data
      - casegambling_uploads:/app/uploads
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3001/api/health"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 20s

volumes:
  casegambling_data:
  casegambling_uploads:
