Skip to content

Add your manifest to the gateway

You have written a manifest for your game (tutorial 2 shows how) and gwctl validate says it is fine. This page shows how to get that file into a gateway: on your machine first, then in production, and how to change it later.

The commands on this page are checked in CI by 02-describe-your-actions.sh.

Way When How
Startup file the first start of a gateway, and every local test --manifest path/to/manifest.yaml
Upload every change after that, in staging and production PUT /v1/studio/manifest, signed with the admin key

The manifest store is the source of truth. --manifest only seeds an empty store.

On start the gateway looks for an active manifest version in its store. If there is none, it stores the file from --manifest as version 1 (actor bootstrap) and serves it. If a version is already active, the file is ignored and the stored version is served. The start log says which one happened:

{"level":"INFO","msg":"manifest","version":1,"sha256":"...","seeded_from_file":true}

seeded_from_file: false means the file was not used. With Postgres (--postgres-url) the store survives restarts, so editing the file and restarting does not change the tools. The compose stack in this repository uses Postgres. Without Postgres the store lives in memory and every restart seeds again from the file.

The reason: in production a studio uploads and rolls back versions while the gateway runs. A restart with an old file on disk must not undo that. The decision is recorded in DECISIONS.md.

Put your manifest in a folder of its own, for example mygame/manifest.yaml in the repository folder, and validate it:

Terminal window
docker compose run --rm dev go run ./cmd/gwctl validate mygame/manifest.yaml
docker compose run --rm dev go run ./cmd/gwctl tools mygame/manifest.yaml

The extension picks the format: .yaml or .yml is read as YAML, anything else as JSON. A YAML manifest saved as manifest.txt fails as invalid JSON.

The repository’s docker-compose.yml runs the gateway on the city demo. Do not edit it. Add a small override file next to it instead, compose.mygame.yml:

# Runs the gateway on your manifest and your backend. Dev only: --dev-auth trusts X-Dev-Player.
services:
gateway:
command:
- --manifest=/etc/mygame/manifest.yaml
- --backend-url=http://host.docker.internal:3000
- --backend-allow-private # your backend is on your machine; dev only
- --addr=0.0.0.0:8080
- --redis-addr=redis:6379
- --ops-addr=0.0.0.0:9091
- --dev-auth
volumes:
- ./mygame:/etc/mygame:ro
extra_hosts:
- "host.docker.internal:host-gateway"

What each part does:

  • command replaces the demo’s flag list. --manifest is the path inside the container.
  • --backend-url is where your game backend listens. host.docker.internal reaches a backend running on your machine (here on port 3000). If your backend runs in compose, use its service name instead, as in http://my-backend:9090.
  • --backend-allow-private lets the gateway call a private or loopback address. It is off by default so a manifest cannot make the gateway call internal hosts. Keep it for local work only.
  • volumes mounts your folder read only. Mount the folder, not the single file, so an editor that replaces the file on save does not leave the container with the old copy.
  • extra_hosts makes host.docker.internal work on Linux. Docker Desktop has it already.

Stop the demo if it runs (it uses the same ports), then start your stack under its own project name. A separate name gives it its own Postgres volume, so the demo’s stored manifest is not picked up instead of yours:

Terminal window
docker compose down
docker compose -p mygame -f docker-compose.yml -f compose.mygame.yml up --build -d
docker compose -p mygame logs gateway | grep '"msg":"manifest"'
curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/tools

The log line shows "seeded_from_file":true and /v1/tools lists your tools. The demo’s city backend also starts, because the gateway service depends on it. It does nothing for you and you can ignore it.

Calls now go to your backend, signed. Your backend should verify the signature (tutorial 3). Every call is signed with GAMEWARDEN_SIGNING_SECRET, dev-secret by default.

Edit mygame/manifest.yaml, validate it again, then reset the store so the file seeds it again:

Terminal window
docker compose -p mygame -f docker-compose.yml -f compose.mygame.yml down -v
docker compose -p mygame -f docker-compose.yml -f compose.mygame.yml up -d

down -v deletes this project’s volumes: the stored manifest, but also its confirmations, grants and audit. That is fine on your machine. A plain restart keeps the old tools, as explained in the rule.

To change the tools without losing state, upload instead, as in the next section.

In production you never restart to change tools. You upload a new version with the admin key (GAMEWARDEN_ADMIN_SECRET), a different key from the one that signs player calls. The upload takes the same file you validated:

Call What it does
PUT /v1/studio/manifest validate and activate a new version. Content-Type: application/yaml for YAML. An invalid file gets 422 and changes nothing
GET /v1/studio/manifest/versions list versions, with who uploaded each and which one is active
POST /v1/studio/manifest/versions/{id}/activate roll back (or forward) to a stored version

The request is signed like every studio call (protocol). Your deploy job can sign it with pkg/agentsig, or with the repository’s studiocall helper, which runs in the dev container:

Terminal window
docker compose run --rm -e GAMEWARDEN_ADMIN_SECRET dev go run ./examples/studiocall \
--url https://gateway.example.com --key-id admin-1 --secret-env GAMEWARDEN_ADMIN_SECRET \
--player ci --content-type application/yaml --body-file mygame/manifest.yaml \
--expect 201 PUT /v1/studio/manifest

Every replica serves the new version within --manifest-poll (15 seconds by default). Calls already running finish with the tools they started with. Tutorial 6 runs the whole flow: upload, list, roll back, and a rejected upload. The endpoints are listed in the studio and admin API.

A good habit: keep the manifest in Git next to your backend code, validate it in CI with gwctl validate, and upload it from CI after a merge. The version list then lines up with your commits, and a rollback is one call.

5. Where the startup file comes from in production

Section titled “5. Where the startup file comes from in production”

The seed still matters for the first start of a new environment.

  • Docker or Compose: mount the file and pass --manifest, as above, without --dev-auth and --backend-allow-private (unless your backend is on a private network you trust). Tutorial 6 has the full flag set.
  • Kubernetes: the Helm chart takes the file and stores it in a ConfigMap: helm install ... --set-file manifest=mygame/manifest.yaml. For JSON also pass --set manifestFile=manifest.json. See tutorial 9 and the runbook.
What you see Why Fix
Old tools after editing the file and restarting the store already has an active version, seeded_from_file: false down -v on your machine, upload in production
The gateway exits with manifest bootstrap in the log the seed file is invalid gwctl validate it and fix every listed problem
The gateway exits with manifest and no such file the --manifest path is wrong inside the container check the volumes mount and the path in --manifest
invalid character errors for a YAML file the extension is not .yaml or .yml, so it was read as JSON rename the file
Every call returns backend_unavailable the backend is down, unreachable from the container, or private without --backend-allow-private check --backend-url from inside the container, see troubleshooting
backend_rejected with a signature message your backend refuses the signature use the same secret on both sides, see tutorial 3