Self-hosting
Run the Plat5 runtime on a server using published images and Docker Compose. (For local laptop development, use the plat5 CLI.)
Architecture
Section titled “Architecture”Internet https://api.example.com → TLS edge (Caddy, nginx, Cloudflare Tunnel, …) → gateway :5001
Docker network (plat5_plat5): postgres, control-plane, gateway, identity + audit (optional, on by default) + valkey (optional, on by default for rate limits)
Your services: Plain HTTP servers on the plat5_plat5 network (e.g. http://api:3000)
IdP: Any OAuth 2.0 issuer of signed JWT access tokens (Auth0, Okta, Keycloak, Plat5 Auth, …)TLS terminates at your edge/load balancer, never in the gateway. Internal ports (INTERNAL_PORT) take no token and must stay inside the private network.
1. Configure and start Plat5
Section titled “1. Configure and start Plat5”git clone https://github.com/plat5dev/plat5.gitcd plat5/composecp .env.template .env# Fill required values + pin PLAT5_VERSION to a released tagdocker compose -f docker-compose.prod.yml --env-file .env up -dRequired in .env:
PLAT5_VERSION— releasedv*tag (do not uselatest)POSTGRES_PASSWORD— URL-safe (hex recommended; raw base64+//breaksDATABASE_URL)AUDIT_OWNER_PASSWORD,AUDIT_WRITER_PASSWORD— passwords for the separateaudit_owner(audit migrate/audit prune) and non-deletingaudit_writer(audit serve) Postgres roles (audit storage)AUTH_CONFIG_FILE(recommended for production: mounted read-only multi-issuer OIDC auth config,reference/config/control-plane-auth.md) and/orADMIN_TOKEN(static bearer token for the control plane Admin API; at least one is required)AUTH_ISSUER,AUTH_ALLOWED_AUDIENCES— your IdP (reference/idp.md);AUTH_JWKS_URIis optional when your IdP serves OIDC / OAuth 2.0 discovery metadata reachable from the gateway container
Optional tuning:
AUTH_JWKS_URI— explicit JWKS URL when your IdP doesn’t expose discovery metadata or when the gateway reaches JWKS over a container-internal hostnameAUTH_SUBJECT_CLAIM— defaults tosub(standard for Plat5 Auth, Auth0, Okta, Keycloak, etc.)AUTH_NAME_CLAIMS— defaults toname,preferred_usernameAUTH_SCOPE_CLAIM— optional JWT claim path for narrowing token permissionsSECRET_BRAND— prefix for API keys and invite tokens (defaultplat5)TRUSTED_PROXIES— CIDR/IP list of your edge proxy soX-Forwarded-ForandX-Forwarded-Protoare honoredCORS_ALLOWED_ORIGINS/CORS_ALLOWED_HEADERS— browser origins (or*) and extra request headers allowed by the gateway (CORS)UPSTREAM_SIGNING_KEY/UPSTREAM_SIGNING_KEY_ID— optional Ed25519 signing of forwarded upstream requests (signing)OTEL_EXPORTER_OTLP_ENDPOINT— optional OTLP collector (reference/telemetry.md)
If your deployment forwards to untrusted external URLs and requires SSRF / private-IP egress protection, enforce it at the network layer (VPC security groups, Kubernetes NetworkPolicy, or an egress proxy) rather than in the gateway (upstream security).
Transport encryption and supply-chain verification
Section titled “Transport encryption and supply-chain verification”For hardened or compliance-scoped deployments (see the SOC 2, ISO 27001 & GDPR playbook):
- Postgres TLS: Append
?sslmode=require(orverify-fullwith your CA mounted into the container’s system trust store) toDATABASE_URLoncontrol-plane,identity, andaudit. - Valkey TLS: Use a
rediss://URL forVALKEY_URLongateway(verified against the container’s system CA bundle viarustls). - Upstream & internal traffic: Point service
urlentries athttps://…(or run inside a private VPC/mesh) and setUPSTREAM_SIGNING_KEYso services can cryptographically verifyX-Plat5-Signature(signing). - Image verification: Published release images on
ghcr.io/plat5dev/*are multi-arch, run as non-root, include BuildKit SBOM and SLSA provenance attestations, and are signed with keyless Cosign (Sigstore):
cosign verify \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ --certificate-identity-regexp '^https://github\.com/plat5dev/plat5/\.github/workflows/release\.yml@refs/tags/v' \ ghcr.io/plat5dev/gateway:${PLAT5_VERSION}
docker buildx imagetools inspect --format '{{json .SBOM}}' ghcr.io/plat5dev/gateway:${PLAT5_VERSION}Optional modules
Section titled “Optional modules”Both audit and rate limiting default to on (AUDIT_URL and VALKEY_URL are required unless turned off):
- Audit mode (
AUDIT_MODE): defaults tosync(fail-closed intent before forward). SetAUDIT_MODE=asyncfor lower write latency via background queuing, orAUDIT_MODE=offto disable audit writes (then don’t run theauditcontainer and omitauditfromservices). - Without rate limiting: set
RATE_LIMIT_ENABLED=falseon the gateway and don’t runvalkey. Rate-limit policies in your config are still accepted at apply and ignored at runtime. When enabled, rate limiting fails open if Valkey is unreachable and resumes automatically when Valkey recovers. - With an external AuthZEN PDP: put the PDP on
plat5_plat5(or an HTTPS endpoint) and setAUTHORIZER_URL(and optionalAUTHORIZER_TOKEN,AUTHORIZER_TIMEOUT,AUTHORIZER_CACHE_TTL,AUTHORIZER_NEGATIVE_CACHE_TTL) ongatewayandidentity(authorizer, env).
Full env reference: reference/env.md.
2. Apply your config
Section titled “2. Apply your config”A fresh deployment has no config: identity and gateway wait for the first apply to the control plane (POST /apply, reference/api/control-plane.md).
The control plane’s port :5002 is not published by default — reach it from inside plat5_plat5 or over an SSH tunnel. Never expose ADMIN_TOKEN to the public internet.
With the plat5 CLI:
plat5 planplat5 applyOr call POST /apply?dry_run=true and POST /apply directly with JSON or YAML (concepts/config.md).
- Rollback: fetch an older revision (
GET /revisions/{rev}orplat5 config pull --revision <n>) and apply it through the same plan. - Drift checks in CI: run
plat5 plan --detailed-exitcodeagainst your repo’s config (exit2means the deployment differs). - Adding/removing kinds: adding a kind takes effect immediately; removing a kind or changing its parent is blocked while any non-purged nodes of that kind exist.
3. Attach your services
Section titled “3. Attach your services”- Put your service container on the
plat5_plat5external network (so the gateway can reach itsurl, e.g.http://api:3000). - Follow the rules in write a service.
- Add the service under
servicesin your config and apply.
To allow browser clients, set CORS_ALLOWED_ORIGINS (and optionally CORS_ALLOWED_HEADERS) on the gateway container (CORS).
Health & verification
Section titled “Health & verification”GET /health/readyon each service’sINTERNAL_PORT(reference/health.md).- Before the first apply,
gatewayandidentitywait for the initial config snapshot before listening on their public ports (/health/readyreturns 503). After apply, an unauthenticated request to a protected route returns 401UNAUTHORIZED. JWKSmust be reachable from the gateway container over HTTPS/HTTP.
Footguns
Section titled “Footguns”- Pick
AUTH_SUBJECT_CLAIMbefore the first sign-in. Changing it later signs existing users in as new users. docker compose down -vwipes Postgres — identity data, audit logs, and applied config revisions.
Images: ghcr.io/plat5dev/{gateway,identity,control-plane,audit}:$PLAT5_VERSION.
- Upgrade
gatewaywith or beforecontrol-plane(an older gateway refuses a snapshot format it doesn’t understand and stays on its last snapshot until upgraded). - Upgrade
control-plane,identity, andaudit. Stored feed bodies stay unchanged until your next apply. - Run a plan on your unchanged config to review any expansion differences, then apply if needed.