# Development overrides -- NOT auto-applied (explicit include required)
#
# Enables hot reload for both API (uvicorn --reload) and Web (next dev)
# with bind-mounted source directories for live code changes.
#
# Usage (any profile):
#   ./compose.sh --dev --profile local up
#   ./compose.sh --dev --profile enterprise up
#   ./compose.sh --dev --profile local-auth up
#
# Or manually:
#   docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile enterprise up

services:
  # -----------------------------------------------------------------
  # API -- hot reload + debugpy port
  # -----------------------------------------------------------------
  skillmeat-api:
    volumes:
      - skillmeat-data:/home/app/.skillmeat
      - ./skillmeat:/app/skillmeat:cached,z
    ports:
      - "${SKILLMEAT_API_PORT:-8080}:8080"
      - "5678:5678"
    environment:
      - SKILLMEAT_HOST=0.0.0.0
      - SKILLMEAT_PORT=8080
      - SKILLMEAT_ENV=development
      - SKILLMEAT_RELOAD=true
    command:
      [
        "uvicorn",
        "skillmeat.api.server:app",
        "--host", "0.0.0.0",
        "--port", "8080",
        "--reload",
        "--reload-dir", "skillmeat",
      ]

  # -----------------------------------------------------------------
  # WEB -- next dev with filesystem polling
  # -----------------------------------------------------------------
  skillmeat-web:
    build:
      context: skillmeat/web
      dockerfile: Dockerfile
      target: dev
    volumes:
      - ./skillmeat/web/app:/app/app:cached,z
      - ./skillmeat/web/components:/app/components:cached,z
      - ./skillmeat/web/hooks:/app/hooks:cached,z
      - ./skillmeat/web/lib:/app/lib:cached,z
      - ./skillmeat/web/types:/app/types:cached,z
    environment:
      # Browser-facing: empty so client uses relative URLs proxied via Next.js rewrites.
      # This works regardless of which host/IP the browser accesses the site from.
      - NEXT_PUBLIC_API_URL=
      # Server-side (SSR) uses internal container hostname
      - INTERNAL_API_URL=http://skillmeat-api:8080
      - NEXT_TELEMETRY_DISABLED=1
      - NODE_ENV=development
      - WATCHPACK_POLLING=true
    command: ["npx", "next", "dev", "--port", "3000", "--hostname", "0.0.0.0"]
