services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: jackbox-backend
    restart: unless-stopped
    environment:
      - PORT=5000
      - NODE_ENV=production
      - DB_PATH=/app/data/jackbox.db
      - JWT_SECRET=${JWT_SECRET:?JWT_SECRET is required}
      - ADMIN_KEY=${ADMIN_KEY:?ADMIN_KEY is required}
      - DEBUG=false
    volumes:
      - jackbox-data:/app/data
      - ./games-list.csv:/app/games-list.csv:ro
    ports:
      - "5000:5000"
    networks:
      - jackbox-network
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:5000/health"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: jackbox-frontend
    restart: unless-stopped
    ports:
      - "3000:80"
    depends_on:
      backend:
        condition: service_healthy
    networks:
      - jackbox-network

networks:
  jackbox-network:
    driver: bridge

volumes:
  jackbox-data:
    driver: local

