version: '3.8'

services:
  api:
    build: .
    container_name: genesis-widget-api
    ports:
      - "8000:8000"
    environment:
      # Elestio Infrastructure (from .env)
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}

      - REDIS_HOST=${REDIS_HOST}
      - REDIS_PORT=${REDIS_PORT}
      - REDIS_USER=${REDIS_USER}
      - REDIS_PASSWORD=${REDIS_PASSWORD}

      - QDRANT_HOST=${QDRANT_HOST}
      - QDRANT_PORT=${QDRANT_PORT}
      - QDRANT_API_KEY=${QDRANT_API_KEY}

      # Telnyx Voice
      - TELNYX_API_KEY=${TELNYX_API_KEY}
      - TELNYX_VOICE=${TELNYX_VOICE:-eucalyptus}
      - TELNYX_MODEL=${TELNYX_MODEL:-google/gemini-2.5-flash}

      # OpenRouter (optional)
      - OPENROUTER_API_KEY=${OPENROUTER_API_KEY}

      # Security
      - JWT_SECRET=${JWT_SECRET}
      - API_KEY_SALT=${API_KEY_SALT}
      - ADMIN_TOKEN=${ADMIN_TOKEN:-genesis_admin_secret_change_me}

      # CORS
      - ALLOWED_ORIGINS=${ALLOWED_ORIGINS}

      # Rate Limiting
      - RATE_LIMIT_PER_MINUTE=${RATE_LIMIT_PER_MINUTE:-60}

    env_file:
      - .env
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

  # Optional: Local development services (comment out for production)
  # postgres:
  #   image: postgres:15-alpine
  #   environment:
  #     POSTGRES_USER: postgres
  #     POSTGRES_PASSWORD: postgres
  #     POSTGRES_DB: genesis_widget
  #   ports:
  #     - "5432:5432"
  #   volumes:
  #     - postgres_data:/var/lib/postgresql/data

  # redis:
  #   image: redis:7-alpine
  #   ports:
  #     - "6379:6379"
  #   command: redis-server --requirepass redis_password

volumes:
  postgres_data:
