Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

9.8 KB
Raw Blame
services:
  clickhouse:
    image: clickhouse/clickhouse-server:24.4.1
    container_name: clickhouse
    environment:
      CLICKHOUSE_PASSWORD: ${OPENLIT_DB_PASSWORD:-OPENLIT}
      CLICKHOUSE_USER: ${OPENLIT_DB_USER:-default}
      CLICKHOUSE_DATABASE: ${OPENLIT_DB_NAME:-openlit}
      CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS: true
    volumes:
      - clickhouse-data:/var/lib/clickhouse
      - ../assets/clickhouse-config.xml:/etc/clickhouse-server/config.d/custom-config.xml:ro
      - ../assets/clickhouse-init.sh:/docker-entrypoint-initdb.d/init.sh:ro
    ports:
      - "9000:9000"
      - "8123:8123"
    healthcheck:
      test: ["CMD-SHELL", "clickhouse-client --user=$${CLICKHOUSE_USER} --password=$${CLICKHOUSE_PASSWORD} --query='SELECT 1' || exit 1"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 100s
    restart: always

  nats:
    image: nats:2.10-alpine
    container_name: nats
    # Auth, per-user permissions, and JetStream limits live in nats.conf.
    # No ports are published: only containers on this network reach NATS,
    # and the monitoring endpoint listens on loopback inside the container.
    command: ["-c", "/etc/nats/nats.conf"]
    environment:
      # Change both passwords for any deployment reachable by others.
      NATS_RECEIVER_PASSWORD: ${NATS_RECEIVER_PASSWORD:-openlit-receiver-change-me}
      NATS_ENGINE_PASSWORD: ${NATS_ENGINE_PASSWORD:-openlit-engine-change-me}
    volumes:
      - nats-data:/data
      - ../assets/nats.conf:/etc/nats/nats.conf:ro
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8222/healthz?js-enabled-only=true || exit 1"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 10s
    restart: always

  openlit:
    image: openlit
    build:
      context: .
      dockerfile: ./Dockerfile
    container_name: openlit
    # Reach host-published Loki/Tempo/Prometheus via host.docker.internal
    # (Linux needs host-gateway; Docker Desktop already provides the alias).
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      TELEMETRY_ENABLED: "true"
      INIT_DB_HOST: clickhouse
      INIT_DB_PORT: 8123
      INIT_DB_DATABASE: ${OPENLIT_DB_NAME:-openlit}
      INIT_DB_USERNAME: ${OPENLIT_DB_USER:-default}
      INIT_DB_PASSWORD: ${OPENLIT_DB_PASSWORD:-OPENLIT}
      SQLITE_DATABASE_URL: file:/app/client/data/data.db
      # Realtime signal fan-out (receiver publishes, engine consumes).
      # Set NATS_URL to an empty string to disable realtime findings.
      NATS_URL: ${NATS_URL-nats://nats:4222}
      NATS_RECEIVER_USER: ${NATS_RECEIVER_USER:-openlit-receiver}
      NATS_RECEIVER_PASSWORD: ${NATS_RECEIVER_PASSWORD:-openlit-receiver-change-me}
      NATS_ENGINE_USER: ${NATS_ENGINE_USER:-openlit-engine}
      NATS_ENGINE_PASSWORD: ${NATS_ENGINE_PASSWORD:-openlit-engine-change-me}
      # Rules can use any span attribute except personal ones (user, session,
      # conversation, email, phone, ip, address, path keys); list those here,
      # comma-separated, to allow them.
      OPENLIT_SIGNAL_ATTRIBUTES: ${OPENLIT_SIGNAL_ATTRIBUTES:-}
      PORT: ${PORT:-3000}
      DOCKER_PORT: ${DOCKER_PORT:-3000}

      # OAuth Environment Variables
      GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
      GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET:-}
      GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
      GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET:-}
      AZURE_AD_CLIENT_ID: ${AZURE_AD_CLIENT_ID:-}
      AZURE_AD_CLIENT_SECRET: ${AZURE_AD_CLIENT_SECRET:-}
      AZURE_AD_TENANT_ID: ${AZURE_AD_TENANT_ID:-}
      OKTA_CLIENT_ID: ${OKTA_CLIENT_ID:-}
      OKTA_CLIENT_SECRET: ${OKTA_CLIENT_SECRET:-}
      OKTA_ISSUER: ${OKTA_ISSUER:-}

    env_file:
      - path: .env
        required: false
    ports:
      - "${PORT:-3000}:${DOCKER_PORT:-3000}"
      - "4317:4317"  # OTLP gRPC receiver
      - "4318:4318"  # OTLP HTTP receiver
    depends_on:
      clickhouse:
        condition: service_healthy
      nats:
        condition: service_healthy
    volumes:
      - openlit-data:/app/client/data
    healthcheck:
      test: ["CMD", "node", "-e", "const ui=process.env.DOCKER_PORT||process.env.PORT||3000;let raw=process.env.OTLP_HTTP_ADDR||'0.0.0.0:4318',host='127.0.0.1',port='4318';if(raw.startsWith('[')){const end=raw.indexOf(']');if(end>1&&raw[end+1]===':'){host=raw.slice(1,end);port=raw.slice(end+2)}}else{const i=raw.lastIndexOf(':');if(i>=0){host=raw.slice(0,i);port=raw.slice(i+1)}}if(host===''||host==='0.0.0.0'||host==='::')host='127.0.0.1';const h=host.includes(':')?'['+host+']':host;Promise.all([fetch('http://127.0.0.1:'+ui),fetch('http://'+h+':'+port+'/health')]).then(rs=>process.exit(rs.every(r=>r.ok)?0:1)).catch(()=>process.exit(1))"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 30s
    restart: always

  # --- Controller + Sample Apps (only with: --profile full) ---
  openlit-controller:
    image: openlit-controller:dev
    build:
      context: ../openlit-controller
      dockerfile: Dockerfile
    container_name: openlit-controller
    profiles: [full]
    privileged: true
    pid: host
    environment:
      OPENLIT_URL: http://openlit:3000
      OTEL_EXPORTER_OTLP_ENDPOINT: http://openlit:4318
      OPENLIT_POLL_INTERVAL: 10s
      OPENLIT_PROC_ROOT: /host/proc
      # Pin a stable instance id so controller config (e.g. custom_llm_hosts)
      # set in the UI survives container recreation. Without this the id is
      # derived from the container hostname and changes on every recreate.
      OPENLIT_INSTANCE_ID: ${OPENLIT_INSTANCE_ID:-dev-controller}
    volumes:
      - /proc:/host/proc:ro
      - /sys/kernel/debug:/sys/kernel/debug:ro
      - /sys/fs/bpf:/sys/fs/bpf:rw
      - /var/run/docker.sock:/var/run/docker.sock:rw
    depends_on:
      openlit:
        condition: service_healthy
    restart: always

  openai-app:
    build: ../examples/openai-chat-app
    container_name: demo-openai-app
    profiles: [full]
    environment:
      OPENAI_API_KEY: "demo-key"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  anthropic-app:
    build: ../examples/anthropic-chat-app
    container_name: demo-anthropic-app
    profiles: [full]
    environment:
      ANTHROPIC_API_KEY: "demo-key"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  gemini-app:
    build: ../examples/gemini-chat-app
    container_name: demo-gemini-app
    profiles: [full]
    environment:
      GEMINI_API_KEY: "demo-key"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  crewai-app:
    build: ../examples/crewai-agent-app
    container_name: demo-crewai-app
    profiles: [full]
    environment:
      OPENAI_API_KEY: "demo-key"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  # JavaScript/TypeScript agent-framework sample app.
  # Runs the real @openai/agents SDK against an in-process OpenAI-compatible
  # mock LLM. It intentionally does not call openlit.init(); use the Agents
  # page to enable controller-managed JS/TS SDK injection and verify framework
  # spans from the injected OpenLIT preload.
  openai-agents-js-app:
    build: ../examples/openai-agents-js-app
    container_name: demo-openai-agents-js-app
    profiles: [full]
    environment:
      AGENT_MODEL: gpt-4o-mini
      REQUEST_INTERVAL_SECONDS: "20"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  non-llm-app:
    build: ../examples/non-llm-http-app
    container_name: demo-non-llm-app
    profiles: [full]
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

  # Self-hosted LiteLLM proxy (an OpenAI-compatible LLM gateway). Uses a
  # mock_response in its config so it serves real OpenAI-format completions
  # without a provider API key. Listens on plain HTTP :4000.
  litellm:
    image: ghcr.io/berriai/litellm:main-latest
    container_name: litellm
    profiles: [full]
    command: ["--config", "/app/config.yaml"]
    environment:
      LITELLM_MASTER_KEY: sk-1234
    volumes:
      - ../examples/litellm-config/config.yaml:/app/config.yaml:ro
    ports:
      - "4000:4000"
    healthcheck:
      test: ["CMD-SHELL", "python -c \"import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:4000/health/liveliness').status==200 else 1)\" || exit 1"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 20s
    restart: always

  # App that calls the LiteLLM proxy via a standard OpenAI client. The
  # controller discovers the connection to litellm:4000 (once litellm:4000 is
  # added to custom_llm_hosts on the controller's Agents page) and surfaces this
  # workload as a Custom LLM Gateway client.
  litellm-app:
    build: ../examples/litellm-chat-app
    container_name: demo-litellm-app
    profiles: [full]
    environment:
      LITELLM_BASE_URL: http://litellm:4000
      LITELLM_API_KEY: sk-1234
      MODEL: gpt-4o-mini
      REQUEST_INTERVAL_SECONDS: "20"
    restart: unless-stopped
    depends_on:
      litellm:
        condition: service_healthy
      openlit:
        condition: service_healthy

  # SDK-instrumented sample agent.
  # Uses openlit.init() to auto-instrument an OpenAI client. An in-process
  # OpenAI-compatible mock LLM lets the calls succeed without a real API key,
  # so the agent shows up on the Agents page as source=SDK with full system
  # prompt + tool definitions + runtime config.
  openlit-sdk-agent-app:
    build: ../examples/openlit-sdk-agent-app
    container_name: demo-openlit-sdk-agent-app
    profiles: [full]
    environment:
      OPENLIT_SERVICE_NAME: travel-assistant
      OTEL_EXPORTER_OTLP_ENDPOINT: http://openlit:4318
      REQUEST_INTERVAL_SECONDS: "20"
    restart: unless-stopped
    depends_on:
      openlit:
        condition: service_healthy

volumes:
  clickhouse-data:
  openlit-data:
  nats-data: