> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trulyagentic.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose (Local BYOC)

> Run append-only PostgreSQL 16 and Portkey OSS gateway locally bound strictly to loopback 127.0.0.1.

The local BYOC stack in [`deploy/docker-compose.yml`](https://github.com/trulyagentic/truly-agentic-governance-kit/blob/main/deploy/docker-compose.yml) runs two containers inside your own host or VM:

1. **`postgres` (`postgres:16-alpine`):** Automatically applies `db/migrations/001_audit_ledger.sql` via `/docker-entrypoint-initdb.d/` to initialize `audit_ledger` (`trg_audit_ledger_immutable`) and `approval_requests`.
2. **`portkey-gateway` (`portkeyai/gateway:latest`):** Routes zero-retention model requests using [`deploy/portkey/config.json`](https://github.com/trulyagentic/truly-agentic-governance-kit/blob/main/deploy/portkey/config.json) with fallback and `x-truly-agentic-retention: zero-training` headers.

> [!WARNING]
>
> All ports bind strictly to `127.0.0.1` (`5432` and `8787`). Never expose `docker-compose.yml` ports to `0.0.0.0` on public cloud hosts; expose services only inside a private VPC subnet or encrypted Tailscale/WireGuard tunnel.

## Start the Stack

**1. Copy the example environment file**

```bash theme={null}
cd truly-agentic-governance-kit
cp deploy/.env.example deploy/.env
```

**2. Populate local secrets in deploy/.env**

```ini theme={null}
POSTGRES_PASSWORD=replace-with-strong-secret
DATABASE_URL=postgres://ta_ledger:replace-with-strong-secret@127.0.0.1:5432/governance_ledger
ANTHROPIC_API_KEY=replace-with-zero-retention-anthropic-key
OPENAI_API_KEY=replace-with-zero-retention-openai-key
SLACK_SIGNING_SECRET=replace-with-slack-app-signing-secret
```

**3. Start PostgreSQL 16 and Portkey Gateway**

```bash theme={null}
docker compose --env-file deploy/.env -f deploy/docker-compose.yml up -d
```

**4. Verify health and loopback bindings**

```bash theme={null}
docker compose -f deploy/docker-compose.yml ps
```

Confirm `postgres` reports `healthy` (`pg_isready -U ta_ledger -d governance_ledger`) and ports bind only to `127.0.0.1`.

## Routing Strategy (`deploy/portkey/config.json`)

The reference gateway config enables retries on HTTP `429`, `500`, `502`, `503`, and `504` across `routine-extraction` (`claude-haiku-4-5`) and `reasoning-fallback` (`gpt-4.1-mini` with `"store": false`) while injecting `x-truly-agentic-retention: zero-training`. For strict VPC-isolated inference in production, point targets at your private AWS Bedrock, GCP Vertex AI, or Azure OpenAI endpoint.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.