# ==============================================
# LLMHosts.com -- Docker Compose (Development)
# God-Mode provisioned | Get-er-DONE L3/L6 compatible
# ==============================================
# Usage:
#   docker compose build dev        # Build the dev container
#   docker compose run --rm dev     # Start interactive shell
#   docker compose run --rm dev pytest tests/  # Run tests
#   docker compose up               # Start all services (dev + db + redis)

services:
  # ---- Primary dev container (all AI agent work happens here) ----
  dev:
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      - .:/workspace:cached
      - dev-ssh:/root/.ssh
      - dev-gh:/root/.config/gh
    environment:
      - GH_TOKEN=${GH_TOKEN}
      - GH_TOKEN_PROJECTS=${GH_TOKEN_PROJECTS}
      - GITHUB_USER=${GITHUB_USER}
      - GITHUB_EMAIL=${GITHUB_EMAIL}
      # Project-specific (uncomment as needed in .env)
      # - DATABASE_URL=${DATABASE_URL}
      # - REDIS_URL=${REDIS_URL}
    working_dir: /workspace
    stdin_open: true
    tty: true
    depends_on: []
    # Uncomment below when database services are added:
    # depends_on:
    #   db:
    #     condition: service_healthy
    #   redis:
    #     condition: service_healthy

  # ---- Next.js Frontend (Cloud Cost Dashboard) ----
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ./frontend:/app:cached
      - /app/node_modules
      - /app/.next
    environment:
      - NEXTAUTH_URL=http://localhost:3000
      - NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-dev-secret-change-me-in-production}
      - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY:-}
      - STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY:-}
      - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET:-}
      - DATABASE_URL=file:./db/llmhost.db
      - LLMHOSTS_API_URL=http://dev:4000

  # ---- PostgreSQL (Phase 2+ SaaS backend) ----
  # Uncomment when Get-er-DONE L3 adds database layer
  # db:
  #   image: postgres:16-alpine
  #   environment:
  #     POSTGRES_DB: llmhost
  #     POSTGRES_USER: llmhost
  #     POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-llmhost_dev}
  #   ports:
  #     - "5432:5432"
  #   volumes:
  #     - pgdata:/var/lib/postgresql/data
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U llmhost"]
  #     interval: 5s
  #     timeout: 5s
  #     retries: 5

  # ---- Redis (Phase 2+ caching/queues) ----
  # Uncomment when Get-er-DONE L3 adds cache layer
  # redis:
  #   image: redis:7-alpine
  #   ports:
  #     - "6379:6379"
  #   healthcheck:
  #     test: ["CMD", "redis-cli", "ping"]
  #     interval: 5s
  #     timeout: 5s
  #     retries: 5

volumes:
  dev-ssh:
    # Persists SSH keys across container rebuilds
  dev-gh:
    # Persists gh CLI auth across container rebuilds
  # pgdata:
  #   # Persists PostgreSQL data
