# The observable docs copilot: app → OTel Collector → Grafana LGTM (Tempo, Prometheus, Loki) [+ Langfuse]
#   docker compose up --build
#   API:      http://localhost:8000/docs
#   Grafana:  http://localhost:3000   (admin / admin: change it) → dashboard "Docs copilot"
# Optional: OPENAI_API_KEY for the real model; COLLECTOR_CONFIG=collector-langfuse.yaml + LANGFUSE_AUTH for Langfuse.
services:
  copilot:
    build: .
    ports: ["8000:8000"]
    environment:
      OTEL_SERVICE_NAME: docs-copilot
      OTEL_EXPORTER_OTLP_ENDPOINT: http://collector:4317
      OPENAI_API_KEY: ${OPENAI_API_KEY:-}
    volumes:
      - ../..:/site:ro                       # the learn-with-project site (ai-engineering/project → ../..)
    depends_on: [collector]

  collector:
    image: otel/opentelemetry-collector-contrib
    command: ["--config=/etc/otelcol/config.yaml"]
    volumes:
      - ./otel/${COLLECTOR_CONFIG:-collector.yaml}:/etc/otelcol/config.yaml:ro
    environment:
      LANGFUSE_AUTH: ${LANGFUSE_AUTH:-}     # base64 of "pk-lf-...:sk-lf-..." (only for collector-langfuse.yaml)
    depends_on: [lgtm]

  lgtm:
    image: grafana/otel-lgtm
    ports: ["3000:3000"]
    volumes:
      - ./grafana/llm-dashboard.json:/otel-lgtm/grafana/conf/provisioning/dashboards/custom/llm-dashboard.json:ro
      - ./grafana/dashboards.yaml:/otel-lgtm/grafana/conf/provisioning/dashboards/custom.yaml:ro
