When kua-deploy is recreating itself (target appName == kua-deploy on same host), the OLD process is about to be killed by the docker daemon mid-flight. Without a handoff, progress would be stuck at deploy:running forever and release-app would poll until timeout. Self-recreate path: (1) pre-mark progress phase=self_recreate_pending with the freshly-built image SHA + deployStartTs + stateless services list; (2) fire-and-forget recreateService (do not await its return — the OLD process is dying anyway); (3) sleep 90s as a ceiling — if were still alive, recreate failed and we throw. On startup, completeSelfRecreate() reads progress-kua-deploy.json; if phase is self_recreate_pending, queries its own container via docker inspect, compares running image SHA to the pre-recreate expected SHA, checks StartedAt > recreate_started_at + state=running, then writes phase=succeeded (or failed) plus a verify struct on the deploy step. Idempotent — no-op if no marker is found. |
||
|---|---|---|
| Dockerfile | ||
| NOTES-image-digest-pinning.md | ||
| README.md | ||
| docker-compose.yml | ||
| kua.json | ||
| package-lock.json | ||
| package.json | ||
| server.js | ||
README.md
kua-deploy
Authoritative deploy orchestrator for the Kua infrastructure fleet. Receives release triggers (admin API and Forgejo webhooks), runs git-pull → migration gate → docker build → recreate → SHA-verify on managed apps.
Split out of coder-core/services/kua-deploy/ on 2026-05-21 to break the self-rebuild loop that ran every coder-core release through this service as a side-effect.
Layout
server.js— Fastify app exposing/api/v1/apps/:app/deploy,/progress,/runtime-status,/webhook/forgejo.Dockerfile— node:22-alpine + docker-cli + ssh + git + kua-vault binary (mounted at runtime).docker-compose.yml— single-service compose project. Joinskua-services+production_proxynetworks.kua.json— release-app manifest (mode: direct,server: bruno).NOTES-image-digest-pinning.md— design notes for deferred prevention #4.
Registry
deploy-registry.json lives in coder-core/services/kua-deploy/deploy-registry.json and is bind-mounted in at /app/deploy-registry.json. This is a transitional arrangement; a future change can migrate the registry into this repo.
Deploying kua-deploy
Via release-app:
release-app kua-deploy
Which goes through kua-deploy's own admin POST /api/v1/apps/kua-deploy/deploy and uses the transient-container recreate pattern (Phase A) so the service can replace its own running container without false-success.
See also
services/kua-deploy/NOTES-image-digest-pinning.mdin this repoinfra-docs/docs/04-operations/deploy-listener.mdin coder-core (current-state callout + deploy_mode reference)