# Runs the whole O2AGENT platform from published images — no git clone, no
# build step. Download this file (and otel-collector-config.yaml, and
# .env.example) into an empty directory and follow the Getting Started guide
# at https://o2agent.pages.dev/getting-started.
#
# Works with any Docker-API-compatible runtime (Docker Engine, Docker
# Desktop, Colima, OrbStack, Rancher Desktop, Podman).

services:
  o2id:
    image: ghcr.io/o2stack/o2id:latest
    environment:
      O2ID_MASTER_KEY: "${O2ID_MASTER_KEY:?Set O2ID_MASTER_KEY in .env (generate one with: openssl rand -hex 32)}"
    ports:
      - "8080:8080"
    volumes:
      - o2id_data:/var/lib/o2id
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
      interval: 2s
      timeout: 5s
      retries: 20

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: o2agent
      POSTGRES_PASSWORD: o2agent
      POSTGRES_DB: o2agent
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U o2agent"]
      interval: 2s
      timeout: 5s
      retries: 15
    volumes:
      - o2agent_postgres_data:/var/lib/postgresql/data

  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.110.0
    command: ["--config=/etc/otel-collector-config.yaml"]
    volumes:
      - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml:ro
    ports:
      - "4318:4318"

  registry-api:
    image: ghcr.io/o2stack/o2agent-registry-api:latest
    environment:
      DB_DSN: postgres://o2agent:o2agent@postgres:5432/o2agent?sslmode=disable
      O2ID_BASE_URL: ${O2ID_BASE_URL:-http://o2id:8080}
      O2ID_TENANT: ${O2ID_TENANT:-system}
      REGISTRY_ADDR: ":8081"
    ports:
      - "8081:8081"
    depends_on:
      postgres:
        condition: service_healthy
      o2id:
        condition: service_healthy

  runtime-worker:
    image: ghcr.io/o2stack/o2agent-runtime-worker:latest
    environment:
      RUNTIME_ADDR: ":8082"
      OPENAI_BASE_URL: ${OPENAI_BASE_URL:-https://api.openai.com/v1}
      OPENAI_API_KEY: ${OPENAI_API_KEY:-}
      OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
    ports:
      - "8082:8082"
    depends_on:
      - otel-collector

  gateway:
    image: ghcr.io/o2stack/o2agent-gateway:latest
    environment:
      O2ID_BASE_URL: ${O2ID_BASE_URL:-http://o2id:8080}
      O2ID_TENANT: ${O2ID_TENANT:-system}
      REGISTRY_URL: http://registry-api:8081
      RUNTIME_URL: http://runtime-worker:8082
      GATEWAY_ADDR: ":8000"
      OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
    ports:
      - "8000:8000"
    depends_on:
      registry-api:
        condition: service_started
      runtime-worker:
        condition: service_started
      otel-collector:
        condition: service_started
      o2id:
        condition: service_healthy

volumes:
  o2agent_postgres_data:
  o2id_data:
