# Paper Dynasty Game Engine - Full Stack Orchestration
# Use this for integration testing, demos, or when you want everything containerized
# For daily dev, see README.md for local development workflow

version: '3.8'

services:
  # Redis cache (shared dependency)
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5

  # FastAPI Game Backend
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    environment:
      # Application
      - APP_ENV=development
      - DEBUG=true
      - SECRET_KEY=${SECRET_KEY:-dev-secret-key-change-in-production}

      # Database (using host machine's PostgreSQL)
      - DATABASE_URL=${DATABASE_URL}

      # Redis
      - REDIS_URL=redis://redis:6379

      # Discord OAuth
      - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
      - DISCORD_CLIENT_SECRET=${DISCORD_CLIENT_SECRET}
      - DISCORD_REDIRECT_URI=${DISCORD_REDIRECT_URI:-http://localhost:3000/auth/callback}

      # League APIs
      - SBA_API_URL=${SBA_API_URL}
      - SBA_API_KEY=${SBA_API_KEY}
      - PD_API_URL=${PD_API_URL}
      - PD_API_KEY=${PD_API_KEY}

      # CORS
      - CORS_ORIGINS=http://localhost:3000,http://localhost:3001
    depends_on:
      redis:
        condition: service_healthy
    volumes:
      # Mount source code for hot-reload during development
      - ./backend/app:/app/app:ro
      - ./backend/logs:/app/logs
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/api/health"]
      interval: 10s
      timeout: 5s
      retries: 5

  # SBA League Frontend
  frontend-sba:
    build:
      context: ./frontend-sba
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - NUXT_PUBLIC_LEAGUE_ID=sba
      - NUXT_PUBLIC_LEAGUE_NAME=Stratomatic Baseball Association
      - NUXT_PUBLIC_API_URL=http://localhost:8000
      - NUXT_PUBLIC_WS_URL=http://localhost:8000
      - NUXT_PUBLIC_DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
      - NUXT_PUBLIC_DISCORD_REDIRECT_URI=http://localhost:3000/auth/callback
    depends_on:
      backend:
        condition: service_healthy
    volumes:
      # Mount source for hot-reload
      - ./frontend-sba:/app
      - /app/node_modules
      - /app/.nuxt
    restart: unless-stopped

  # PD League Frontend
  frontend-pd:
    build:
      context: ./frontend-pd
      dockerfile: Dockerfile
    ports:
      - "3001:3001"
    environment:
      - NUXT_PUBLIC_LEAGUE_ID=pd
      - NUXT_PUBLIC_LEAGUE_NAME=Paper Dynasty
      - NUXT_PUBLIC_API_URL=http://localhost:8000
      - NUXT_PUBLIC_WS_URL=http://localhost:8000
      - NUXT_PUBLIC_DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
      - NUXT_PUBLIC_DISCORD_REDIRECT_URI=http://localhost:3001/auth/callback
    depends_on:
      backend:
        condition: service_healthy
    volumes:
      # Mount source for hot-reload
      - ./frontend-pd:/app
      - /app/node_modules
      - /app/.nuxt
    restart: unless-stopped

volumes:
  redis_data:

networks:
  default:
    name: paperdynasty-network