services: # Profile-gated so `docker compose up` brings up only the supporting # services (postgres, valkey) for host-side `cargo nextest run`. CI and # anyone wanting the fully containerized run opts in with `--profile # tests`. test: profiles: ["tests"] image: tensorzero/nanogateway-test:${NANOGATEWAY_TEST_TAG:-local} build: context: crates/ dockerfile: Dockerfile.tests environment: ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-} OPENAI_API_KEY: ${OPENAI_API_KEY:-} OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-} SGLANG_API_KEY: ${SGLANG_API_KEY:-} BASETEN_API_KEY: ${BASETEN_API_KEY:-} FIREWORKS_API_KEY: ${FIREWORKS_API_KEY:-} GEMINI_API_KEY: ${GEMINI_API_KEY:-} MISTRAL_API_KEY: ${MISTRAL_API_KEY:-} TOGETHER_API_KEY: ${TOGETHER_API_KEY:-} VLLM_API_KEY: ${VLLM_API_KEY:-} MODAL_KEY: ${MODAL_KEY:-} MODAL_SECRET: ${MODAL_SECRET:-} XAI_API_KEY: ${XAI_API_KEY:-} AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-} AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-} AWS_MANTLE_API_KEY: ${AWS_MANTLE_API_KEY:-} AWS_REGION: ${AWS_REGION:-} GOOGLE_APPLICATION_CREDENTIALS: /app/gcp_jwt_key.json GOOGLE_CLOUD_PROJECT: ${GOOGLE_CLOUD_PROJECT:-} # Required by the `test_otel_exact_match_azure_openai_chat` e2e test. # The hostname / deployment / api-version vary per tenant, so the # test reads them from the env rather than pinning a builtin. # `AZURE_AI_FOUNDRY_*` to match the existing GH secret/var naming. AZURE_AI_FOUNDRY_API_KEY: ${AZURE_AI_FOUNDRY_API_KEY:-} AZURE_AI_FOUNDRY_HOSTNAME: ${AZURE_AI_FOUNDRY_HOSTNAME:-} AZURE_AI_FOUNDRY_DEPLOYMENT: ${AZURE_AI_FOUNDRY_DEPLOYMENT:-} AZURE_AI_FOUNDRY_API_VERSION: ${AZURE_AI_FOUNDRY_API_VERSION:-} # Per-resource api-key for the `t0-dev-eastus2-resource` Foundry # resource that hosts the Anthropic Claude and Kimi-K2.5 OSS # deployments. AZURE_EAST2_API_KEY: ${AZURE_EAST2_API_KEY:-} # When set, the gateway's reqwest client routes outbound provider calls # through the MITM cache (gated by the `e2e_tests` feature, which is on # for nextest archive builds). Default empty so `docker compose # --profile tests run --rm test` works locally without spinning up the # proxy; CI sets this to `http://provider-proxy:3003` and additionally # passes `--profile provider-proxy`. NANOGATEWAY_E2E_PROXY: ${NANOGATEWAY_E2E_PROXY:-} # Auth-enabled e2e tests connect to the postgres service below via this # URL. The auth tests skip themselves when the var is unset, so this # only matters when the postgres service is up. NANOGATEWAY_POSTGRES_URL: ${NANOGATEWAY_POSTGRES_URL:-postgres://nanogateway:nanogateway@postgres:5432/nanogateway} # The vendored `tensorzero-auth` crate's e2e tests use `#[sqlx::test]`, # which reads `DATABASE_URL` to create a fresh per-test database against # the same postgres service. Point at the same URL as # `NANOGATEWAY_POSTGRES_URL` so both test suites share the instance. # The `nanogateway` superuser created by the postgres image has # `CREATEDB`, which `#[sqlx::test]` needs. DATABASE_URL: ${DATABASE_URL:-postgres://nanogateway:nanogateway@postgres:5432/nanogateway} # Rate-limiting integration tests connect to the valkey service below # via this URL. Tests skip themselves when unset; the rate-limiting # crate's tests pin themselves to specific logical DBs (11–15), so the # base URL here intentionally has no `/` suffix. NANOGATEWAY_VALKEY_URL: ${NANOGATEWAY_VALKEY_URL:-redis://valkey:6379} volumes: # Bind the host SA-key file into the container at a fixed path. When the # host var is unset (local dev without GCP creds), the default points at a # nonexistent file; Docker creates an empty directory at the target, ADC # fails to parse, and the builtin `gcp_vertex` provider gets skipped at # startup — leaving non-GCP tests unaffected. - ${GCP_JWT_KEY_PATH:-./gcp_jwt_key.json}:/app/gcp_jwt_key.json:ro # Compose silently ignores depends_on entries pointing at services not in # an active profile, so this only takes effect when `--profile # provider-proxy` is passed. depends_on: provider-proxy: condition: service_healthy required: false postgres: condition: service_healthy valkey: condition: service_healthy postgres: image: postgres:18-alpine environment: POSTGRES_USER: nanogateway POSTGRES_PASSWORD: nanogateway POSTGRES_DB: nanogateway ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U nanogateway -d nanogateway"] interval: 1s timeout: 1s retries: 30 valkey: image: valkey/valkey:8-alpine ports: - "6379:6379" healthcheck: test: ["CMD", "valkey-cli", "ping"] interval: 1s timeout: 1s retries: 30 # Arize Phoenix — local OTel viewer for the `gen_ai.*` semantic conventions # the gateway emits. Profile-gated so `docker compose up` keeps a minimal # surface; `docker compose --profile dev up -d` brings up Phoenix on # http://localhost:6006 (UI + OTLP/HTTP at `/v1/traces`). # # Phoenix is purpose-built for LLM tracing — messages render as chat # threads, tool calls are structured, prompts/completions/streaming are # first-class. See `dev/README.md` for the one-command flow. # # No volume by design: this is a dev viewer, not a long-lived store. # `docker compose --profile dev down` wipes the traces with the container. phoenix: profiles: ["dev"] # Pin to a major to avoid surprise UI/wire breakage on `docker compose # pull`; the `15` tag tracks 15.x patches. image: arizephoenix/phoenix:15 ports: # UI + OTLP/HTTP. Gateway env: # OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:6006/v1/traces # OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf - "6006:6006" # OTLP/gRPC. Unused by the gateway (we ship http/protobuf), exposed # for parity if someone wires another producer. - "4317:4317" healthcheck: # Phoenix's base image is Python; using `python -c` avoids depending # on curl/wget being present, which varies across the image variants. test: [ "CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:6006/healthz', timeout=1).status==200 else 1)", ] interval: 2s timeout: 2s retries: 30 start_period: 5s # Caching MITM proxy that records (and replays) provider HTTPS calls made by # the gateway during e2e tests. Profile-gated so `docker compose --profile # tests run --rm test` still works locally without it. Pinned to a tensorzero/tensorzero # SHA: the provider-proxy crate lives there and is not republished under a # stable tag. Cache mode is configurable via PROVIDER_PROXY_CACHE_MODE # (read-old-write-new | read-only | read-write). provider-proxy: profiles: ["provider-proxy"] image: tensorzero/provider-proxy:sha-e2bde73cf96b4bf8331a1eb52e4ffc666c74c581 user: "${DOCKER_UID:-1000}:${DOCKER_GID:-1000}" volumes: - ./ci/provider-proxy-cache:/app/ci/provider-proxy-cache command: [ "--cache-path", "/app/ci/provider-proxy-cache", "--mode", "${PROVIDER_PROXY_CACHE_MODE:-read-old-write-new}", # Don't reject openrouter.ai requests for missing # `X-Title: TensorZero` / `HTTP-Referer: https://www.tensorzero.com/` # headers — nanogateway is its own product and doesn't tag itself # as TensorZero on the wire. "--check-openrouter-headers=false", ] healthcheck: start_period: 10s start_interval: 1s timeout: 1s