Skip to Content
AgentShield
Self-Hosting

Docker Compose

Run AgentShield with Docker Compose. Data services, the app profile, the observability profile, configuration overrides, and lifecycle commands.

docker-compose.yml at the repository root describes the whole stack. Profiles let you start only what you need.

Development credentials

Compose uses known development values and binds every published port to 127.0.0.1. It is for workstations and CI. For shared environments, use the Kubernetes production overlay or equivalent hardening.

Profiles

CommandServices
docker compose up -dPostgreSQL, Redis, NATS (JetStream), MinIO, MinIO bucket init, Mailpit
docker compose --profile app up -d --buildAlso: intelligence, gateway, event-relay, control-plane, dashboard
docker compose --profile app --profile observability up -d --buildAlso: Prometheus and Grafana

Start the full stack

docker compose --profile app up -d --build
docker compose --profile app run --rm control-plane node apps/control-plane/dist/bootstrap.js
docker compose ps
URLService
http://127.0.0.1:3000Dashboard
http://127.0.0.1:8080Control plane API
http://127.0.0.1:8081Gateway API
http://127.0.0.1:8082Intelligence engine
http://127.0.0.1:8083Event relay health
http://127.0.0.1:8025Mailpit (catches invitation email)
http://127.0.0.1:9001MinIO console
http://127.0.0.1:8222NATS monitoring
http://127.0.0.1:9090, :3001Prometheus, Grafana (observability profile)

How services are wired

  • The gateway connects to postgres, redis, and intelligence on the Compose network, with INTELLIGENCE_URL=http://intelligence:8082.
  • The event relay connects to postgres, nats, and minio, and writes to the agentshield-evidence bucket created by minio-init.
  • The control plane connects to postgres, minio (evidence reads), and mailpit (SMTP_URL=smtp://mailpit:1025).
  • The dashboard reaches the control plane at http://control-plane:8080.
  • Services wait for their dependencies' health checks before starting.

In development, Compose connects services as the schema owner, which bypasses row level security. The Kubernetes dev overlay uses agentshield_app everywhere if you want to exercise RLS locally.

Hardening applied

Every application container runs with:

read_only: true
security_opt: ["no-new-privileges:true"]
cap_drop: ["ALL"]

and as a non-root user, with a health check. Base images are pinned by digest.

Enable http.request

The gateway registers only sample.echo unless GATEWAY_TOOLS_CONFIG names a file inside the container. Mount one with an override file:

docker-compose.override.yml
services:
  gateway:
    volumes:
      - ./docs/examples/gateway-tools.json:/etc/agentshield/gateway-tools.json:ro
    environment:
      GATEWAY_TOOLS_CONFIG: /etc/agentshield/gateway-tools.json
      AGENTSHIELD_GITHUB_AUTHORIZATION: ${AGENTSHIELD_GITHUB_AUTHORIZATION}

The example file injects a GitHub credential, so the gateway refuses to start until AGENTSHIELD_GITHUB_AUTHORIZATION is set, for example to Bearer <token>.

Override settings

Copy .env.example to .env to change ports or development credentials:

cp .env.example .env

See Environment variables for every Compose variable.

Migrations

PostgreSQL applies every file in infrastructure/docker/postgres/migrations/ in lexical order when the data volume is first created. An existing volume does not pick up new files. To apply a newer migration to an existing volume:

docker compose exec -T postgres psql -U agentshield -d agentshield \
  < infrastructure/docker/postgres/migrations/0006_event_pipeline.sql

Each migration is safe to run twice. Check schema_migrations to see which are applied.

Lifecycle

docker compose --profile app logs -f gateway     # follow one service
docker compose --profile app restart gateway     # restart after config changes
docker compose --profile app down                # stop, keep volumes
docker compose --profile app down -v             # stop and delete all local data

Was this page helpful?

On this page