One-click Spillway updates
Status: proposed 2026-11-18. Phase 1 (the Docker updater and Render deploy hooks) is built. Phase 2 is built except the updater updating itself and the zero-downtime switch, which moved to later phases (Phases says why). Phase 3 follows.
Modules, kits, themes and brands update with one click under Admin → Updates. Spillway itself does not: on a server you run yourself, someone has to run docker compose pull && docker compose up -d, or git pull and rebuild. This design makes Update to X a button for anyone on a standard install: a short plan, a live checklist while it runs, the public site staying readable, and the previous version put back by itself when the new one does not start.
Hosted sites (HOST_API_URL set) are not part of this: their host installs new versions, and the Updates card keeps saying so.
Why a companion process
A running server cannot safely replace itself. Pulling an image, stopping its own container and starting another needs rights over the container runtime that the web process must never hold, and once the old process stops there is nothing left to watch the new one start or to put the old one back. So the work belongs to a small updater outside the Spillway server:
- the admin asks the server, the server asks the updater, and the updater does the work and reports progress;
- the updater is the only process alive for the whole update, so it owns the live state;
- the updater has the narrowest rights that can do the job, and never trusts the server's word about which image to run.
Updater kinds
The kind is chosen by configuration on the Spillway server. With none configured, the Updates card keeps today's instructions.
| Kind | Configured with | For | Phase |
|---|---|---|---|
| Docker | SPILLWAY_UPDATER_URL, SPILLWAY_UPDATER_SECRET | Docker Compose installs: a companion container that may only pull the Spillway image and recreate the Spillway container | 1 |
| Deploy hook | SPILLWAY_DEPLOY_HOOK_URL | Installs made with a deploy button: the platform's deploy API replaces the service | 1 (Render), later (Railway) |
| Fly Machines | SPILLWAY_FLY_API_TOKEN | Fly.io apps: the Machines API sets the image of the server's own Machine | 2 |
| Kubernetes | a Job or small controller that patches the Deployment's image | 3 | |
| Source checkout | a signed prebuilt release bundle swapped in by the supervisor | 3 |
Docker (phase 1)
spillway updater is a tiny HTTP service in the Spillway image itself (packages/core/src/updater/), run as a second service in the standard docker-compose.yml under the updater profile, next to a Docker socket proxy:
spillway ──(shared secret, compose network)──▶ updater ──(tcp, internal network)──▶ docker-proxy (Spillway's own) ──▶ /var/run/docker.sock
▲ │
└──────────── /healthz (compose network) ◀──────┘
- The Docker proxy (phase 2: Spillway's own, below; phase 1 used a generic socket proxy with an allow-list of paths) runs as an unprivileged user in the socket's group (
DOCKER_GID), holds the socket, accepts connections only from theupdatercontainer, and judges every call against the containers it guards. The updater never sees the raw socket and refuses aDOCKER_HOSTthat is nottcp://orhttp://. - The updater listens on the compose network only (no published port), answers only clients on private addresses that send the shared secret, and re-checks every request against the signed core feed itself (below), so a compromised Spillway server cannot make it run an image of its choosing.
- Recreating the container works the way
docker compose updoes: read the running container and its image, create the new container from the same settings (environment, volumes, ports, networks and their aliases, restart policy, labels), minus what came from the old image (itsENVdefaults, command, labels), so the new image's own defaults apply. The new image is then tagged with the reference the compose file names (ghcr.io/kwall-llc/spillway-cms:latest, say), so a laterdocker compose up -dkeeps the new version instead of going back. Docker does not say which environment entries came from the compose file and which from the image, so an entry the compose file sets to the image's own default (PORT=3000) follows the new image's default; Spillway keeps those defaults stable.
The Docker proxy (phase 2)
A proxy that allows calls by path cannot tell a faithful copy of the Spillway container from a privileged one with the host's root mounted: both are POST /containers/create. So the proxy is Spillway's own (packages/core/src/updater/proxy.ts, spillway docker-proxy, run as node packages/core/dist/updater/proxy.js so it loads nothing of the server), in the same image, and reads the create request:
- What it guards: the compose services in
SPILLWAY_PROXY_SERVICES(spillwayandupdater) of its own compose project, found from its own container's labels, or the containers named inSPILLWAY_PROXY_CONTAINERSwithout Compose. Without either it guards nothing and refuses everything. Every other container on the host is invisible: a list is filtered, and reading, starting, stopping, renaming or removing one is refused (an updater cannot read a database container's password from its environment). - A create is a copy. The request names the container it replaces (
?name=; the running one has stepped aside as<name>-previous-<its id>), and exactly one guarded container must carry that name. The proxy reads that container and refuses the request unless the host settings are exactly its own (no privileged mode, capabilities, devices, new mounts, another network or PID mode), every environment entry and label is one it has (the compose image label aside, which names the new image), every other setting (command, user, working directory, health check, exposed ports) is its own or left to the new image, and the networks and aliases are a subset of its own with no other endpoint settings. - Images come only from the repositories the guarded containers run (the name they were created with and the names their images carry): pulled only by digest (
fromSrcimports refused), tagged only into those repositories, read only when they belong to them, and run only when they do. - Renames go only to the container's own name or
<name>-previous-<its id>; removals never take volumes; exec, attach, archives, volumes, networks, builds, the swarm and plugin APIs and everything else are refused before they reach Docker. Calls are forwarded by container id, so the container checked is the one Docker acts on. - Clients: the addresses
SPILLWAY_PROXY_ALLOW_FROM(updater) resolves to, looked up again when the updater is recreated; loopback may only ping (the container's health check).
What a compromised updater can still do: stop or remove the guarded containers (the volumes stay), and run another image of the same repository with the same settings. It cannot run an image of its choosing or give any container more than Spillway already has. The signed feed is not checked here: the proxy sits on an internal network without internet, and the server and the updater check it.
Deploy hooks (phase 1: Render)
An install made with the Deploy to Render button runs the image from render.yaml. Render's deploy hook deploys a given image when called with imgURL, and accepts only the image the service already runs (any tag or digest of it). The Spillway server is its own client here: it calls the hook with ghcr.io/kwall-llc/spillway-cms@sha256:<digest>, and Render replaces the service. There is no companion, so the server keeps the progress in its data directory, and the version that starts next finishes the run (below).
- Fly Machines: phase 2, below.
- Railway (later): Railway's public API is GraphQL with an account or team token that can change every service it can see; there is no deploy hook scoped to one service. Railway installs keep the template's redeploy.
Fly Machines (phase 2)
Updating a Machine's image is one call to the Machines API, and the server is its own client, as with Render (packages/core/src/updates/fly.ts):
- The token is a deploy token (
fly tokens create deploy --app <app>), stored as the Fly secretSPILLWAY_FLY_API_TOKEN. It can change only that app; it never appears in a message, a log line or the audit log (Fly's answers are scrubbed of it). The app and the Machine come from Fly's ownFLY_APP_NAMEandFLY_MACHINE_ID, so the server updates only the Machine it runs on. - One Machine only. An app with more than one started Machine (several processes on Postgres) is refused with the reason: the others would keep the old version on a migrated database. They update with
fly deploy. - The call: read the Machine, write the marker (with the image to go back to, pinned by digest: the signed feed's digest for the running version, else Fly's
image_refdigest, since a tag such aslatestmay already name the new version), then post its configuration back with onlyimagechanged toimage@digestandcurrent_version, so a change made in between is refused rather than overwritten. Fly stops this server and starts the Machine on the new image. - The end is the deploy hook's: the new version records Updated when it starts; one that fails while starting asks Fly once for the previous image, whose start restores the backup and records Rolled back.
- The start watchdog. With Render the old service keeps running until the new one passes Render's health check; Fly has stopped the old Machine by then. So a new version that is not listening within
SPILLWAY_UPDATER_HEALTH_TIMEOUTseconds (300; a migration that hangs, a start that never finishes) asks Fly for the previous image itself and exits. fly deploylater sets the image fromfly.tomlor--imageagain. That stays the operator's: keep it atlatestor theX.Ytag. An older exact version refuses to start on the migrated database, which is the safe failure.
Postgres (phase 2)
Phase 1 refused Postgres because the rollback had nothing to put back. Phase 2 (packages/core/src/updates/postgres.ts):
- The tools in the image.
pg_dumpandpg_restoreof PostgreSQL 17 are copied into the image from the PostgreSQL project's Debian packages, with libpq: about 2 MB, plus about 3 MB of Kerberos and LDAP libraries libpq links. The wholepostgresql-clientpackage was left out because it brings Perl andpsql(tens of megabytes) for two binaries. The repository key is checked against its hash. A client dumps servers up to its own major version, soPG_CLIENTis a build argument (18for a Postgres 18 server,0to leave them out); one-click updates on Postgres are offered only when both tools are onPATHand at least the server's major version, checked every five minutes, and the card says why otherwise. - The backup is
pg_dump --format=custom --no-owner --no-privileges --schema=<schema>of the schema Spillway uses (current_schema():public, or the one the connection'ssearch_pathnames), intoDATA_DIR/updates/<run>/spillway.pgdump. The password goes to the tools asPGPASSWORD, never on a command line; node-postgres'ssl=truebecomes libpq'ssslmode=require. - The rollback, by the old version as it starts and before it opens the database, when the database records migrations it does not know: the migrated schema is renamed
<schema>_failed_<run>(kept, asafter-failed/is on SQLite), and the dump is restored withpg_restore --single-transaction --exit-on-error. A restore that fails drops what it made and renames the migrated schema back, so the database is never left half restored; the old version then refuses to start on it, as it would without the rollback, and the log says why. Renaming a schema needs its owner, which the database owner is (POSTGRES_USERin the compose file,fly postgres attach). - Read-only covers the dump as it covers the SQLite copy. Several processes on one database are not covered: the Docker updater updates one container (it refuses a compose service scaled past one), and Fly refuses an app with several Machines.
Scheduled patch updates (phase 2)
An opt-in setting, Install Spillway patch updates automatically under Admin → Updates (autoPatchSpillway, off), with an update window (spillwayWindow: a day or every day, a start hour and a length in hours, in UTC; every day from 03:00 for three hours by default). It is the X.Y policy of Taking patches automatically without Watchtower or cron (packages/core/src/updates/auto-spillway.ts):
- A ticker step, inside the window, picks the newest patch release of the running minor that the signed feed lists with an image digest (never a minor or major release, never a pre-release; the same rule as module patch updates) and starts the same run as Update to, with every check: the feed signature on the server and again in the updater, the digest, the backup, read-only, the health check, the rollback.
- Once per window: the window is claimed in
update_state(compare-and-swap), so several processes on one database start one update, and a run that does not start gives the window back. - The run has no actor (
actorIdnull,automatic: trueon the run and in thespillway.update.startaudit row). When it ends, the administrators get the result by email, and a version that failed or was rolled back is held (spillwayHeld): it is not tried again automatically, a later patch is, and an administrator can still install it by hand. - It runs only where Update to can: an updater set up, not a hosted site, a database it can back up. The settings response says why not (
spillwayAuto.reason) and when the window opens next.
Later phases
- Kubernetes (phase 3): a Job with a service account that may
patchone Deployment's image and read its rollout, created from a Helm value; the rollout's readiness probe on/healthzis the health check andkubectl rollout undothe way back. - Source checkouts (phase 3):
pnpm startunder a supervisor (systemd or the Docker restart policy). The release workflow publishes a signed, prebuilt bundle per version; the server downloads and verifies it, unpacks it beside the current one, writes a marker and exits with code 75 (as Restore does,e2e/smoke-restore.mjs), and the start script switches thecurrentlink before Node starts. A start that fails switches the link back.
The flow
Update to X shows only for administrators (users.manage from a global role, as the update settings are) on a server with an updater. It opens a panel with What is new (the release's summary from the core feed), whether it fixes a security issue, and the plan:
- Back up. The server copies its database with
spillway backup's own code (VACUUM INTO, verified withquick_check) intoDATA_DIR/updates/<run>/spillway.db. From here on the instance is read-only for signed-in people (as withSPILLWAY_READ_ONLY): the admin says why, and nothing edited during the update can be lost by a rollback. - Download and verify. The image digest for X must be listed in the signed core feed (below). The updater checks the feed's signature itself, pulls
image@digest(Docker refuses content that does not hash to the digest) and checks that the pulled image carries that digest and the version label X. Anything else stops the update here, with the site untouched. - Switch. The old container stops and the new one is created in its place. The public site is unreachable from this moment until the new version answers, usually a few seconds plus the time its migrations take.
- Start the new version. Migrations run on boot, as on every upgrade.
- Health check.
/healthzmust answer with version X within five minutes (SPILLWAY_UPDATER_HEALTH_TIMEOUT); a container that exits fails at once. - Done. The old container is removed (its image stays until
docker image prune), the new image takes the compose file's tag, the instance is writable again, and the audit log records the outcome.
On failure after the switch, the updater stops and removes the new container and starts the old one again. The old version finds the update's marker in its data directory on boot (below): when the new version had migrated the database, it moves that database aside to DATA_DIR/updates/<run>/after-failed/ and puts the backup from step 1 back before opening it, so it starts on the data it had. It then records the run as Rolled back with the reason, and the instance is writable again. A failure before the switch changes nothing but the run's status.
How progress survives the restart
The server cannot keep the checklist by itself (it is the thing being replaced), and the browser cannot talk to the updater (it listens on the compose network only, behind a secret). So:
- The updater owns the live state of a Docker update: the steps, their times and the error, in memory and in a small state file, answered at
GET /v1/status. - The server reads it through
GET /api/updates/spillway, which the admin polls every two seconds, merges it into the run's row (spillway_update, migration 0083) and finishes the run when the updater reports an end. A ticker step does the same every minute, so a run finishes even when nobody watches. - While the server restarts, the poll fails. The admin keeps the last checklist on screen with Switch in progress and "The site is restarting; this page reconnects by itself", and polls again with a growing delay. The session survives: the new version reads the same database and session secret, and a rolled-back one reads the backup taken a minute earlier.
- The marker file (
DATA_DIR/updates/pending.json) tells whichever version starts next that an update is under way: which run, from which version to which, and where the backup is. The new version stays read-only until the run is finished; the old version, starting again, knows it was rolled back. - With a deploy hook there is no updater to ask. The server writes the marker and calls the hook. The version that starts next finishes the run: the new version (it is up, so its health check passed) records Updated; the old version (the platform kept or put it back) records Rolled back or Failed. If the new version fails while starting, before it serves anything, it calls the hook once more with the previous image, and the old version restores the backup when it starts. If nothing has started after 20 minutes, the old server, still running, records Failed and lifts the read-only mode.
The run's row is written before the backup, so the backup holds it too: after a rollback the restored row is the same run, and the old version only changes its status.
The signed core feed
The core feed (/registry/v1/core.json) was informational and unsigned. It gains two things:
images: for each recent release, the image and the digest of its multi-arch index ({ "version": "0.1.20", "image": "ghcr.io/kwall-llc/spillway-cms", "digest": "sha256:..." }). The release workflow knows the digest only after it pushed the image, so it cannot be built into that image: the workflow writescore-images.json(the previous release's file plus the new digest,scripts/core-images.mjs) and attaches it to the GitHub release, and a registry host serves the file named byREGISTRY_CORE_IMAGES. spillwaycms.com downloads it with the release it pins on every deploy.generatedAtandsignature: the registry host signs the feed with its registry signing key (REGISTRY_SIGNING_KEY), over the same canonical JSON as the index. A server verifies it with the registry's public key (REGISTRY_PUBLIC_KEY, or the built-in key for spillwaycms.com), and the updater verifies it again with its own copy of the key.
A digest from an unsigned or badly signed feed is never used: the update is not offered, and the card says why. The feed stays readable without a signature for the version check, the email and the security banner, which install nothing.
Security
- Nothing when unset. Without
SPILLWAY_UPDATER_URLandSPILLWAY_UPDATER_SECRET(orSPILLWAY_DEPLOY_HOOK_URL, orSPILLWAY_FLY_API_TOKEN) the server offers no button and calls nothing. The updater refuses to start without a secret of at least 32 characters. - Only its own server. The updater answers only private addresses (loopback, RFC 1918, unique-local IPv6) and only requests carrying the secret (compared in constant time). The compose file publishes no port for it.
- Only signed releases. The digest must be the one the signed feed lists for that version, checked by the server and again by the updater; the pulled image must carry that digest. The image repository must be the feed's.
- Never older. A version that is not newer than the one running is refused by the server and by the updater.
- The narrowest Docker rights. The Docker proxy allows only the calls above, only from the updater, only on the guarded containers, and a create only as a copy of the running container with an image of its repository (The Docker proxy).
- Platform tokens. The Render deploy hook and the Fly deploy token each reach one service or app; neither is shown, logged or audited, and Fly's error messages are scrubbed of the token.
- Automatic updates are opt-in and limited to patch releases of the running minor, with the same checks as Update to; administrators are emailed every outcome.
- Administrators only, everything audited. Starting needs an administrator; the start (
spillway.update.start), a refused request (spillway.update.refused) and the outcome (spillway.update.finish, with the steps and the error) are audit rows. The updater logs every request it receives. - Hosted sites never offer it, whatever the environment says.
- Postgres from phase 2. The rollback renames the migrated schema aside and restores a
pg_dump; it is offered only with client tools at least as new as the server.
Phases
- Docker and Render (this change): the core feed's digests and signature, the release workflow's
core-images.json,spillway updaterwith the Docker updater, the Render deploy hook, the compose services, the Updates panel and checklist, the boot-time rollback, read-only during the update, the audit rows, unit tests with a fake Docker API and a fake deploy hook, and the e2e smokee2e/smoke-updater.mjsagainst a real Docker. - Hardening and reach (built): Spillway's own Docker proxy that compares a create request with the running container; Postgres with
pg_dumpandpg_restorein the image; Fly Machines; scheduled one-click patch updates. Two items of the original plan moved to later phases:- The updater updating itself after Spillway. The updater's image follows the tag the compose file names, which a successful update moves, so the next
docker compose up -druns the new updater; its protocol with the server is versioned and kept stable. Replacing itself while it runs needs a hand-over (a new updater started beside the old, the old one stopping itself, the new one removing it) in which nothing watches the switch, and a broken new updater could not be put back by anyone. The proxy already guards theupdaterservice, so this can follow without loosening it. - A zero-downtime switch behind a reverse proxy. Running the new version beside the old one means two versions on one database while the new one migrates it: the old code would serve against a schema it was never tested with, and on SQLite the two processes would contend for one file. It needs migrations that are safe for the previous version (expand, then contract a release later), which Spillway's migrations do not promise, and a reverse proxy the updater can switch. Until then the switch costs a few seconds plus the migrations.
- The updater updating itself after Spillway. The updater's image follows the tag the compose file names, which a successful update moves, so the next
- Kubernetes and source checkouts, as above.
Where things are
packages/core/src/updates/one-click.ts | the server side: the updater kinds, the run, the marker, read-only, the boot-time rollback |
packages/core/src/updates/deploy-hook.ts | the Render deploy hook |
packages/core/src/updates/fly.ts | the Fly Machines API |
packages/core/src/updates/postgres.ts | pg_dump before, pg_restore on rollback |
packages/core/src/updates/auto-spillway.ts | scheduled patch updates: the window, the patch, the ticker step |
packages/core/src/updater/proxy.ts | spillway docker-proxy |
packages/core/src/updates/images.ts | the feed's image digests on a registry host (REGISTRY_CORE_IMAGES) and their signature check |
packages/core/src/updater/ | spillway updater: the HTTP service, the Docker client and the recreate steps |
packages/core/src/routes/updates.ts | GET and POST /api/updates/spillway |
packages/admin/src/screens/updates/SpillwayUpdate.tsx | the panel and the checklist |
scripts/core-images.mjs | core-images.json for the GitHub release |
docker-compose.yml | the updater and docker-proxy services (profile updater) |
Dockerfile | pg_dump and pg_restore (PG_CLIENT) |
packages/core/src/test/one-click-*.test.ts | the tests, with a fake Docker API (on a Unix socket behind the proxy), a fake deploy hook, a fake Machines API, a fake feed, and real pg_dump and pg_restore on the Postgres lane |
e2e/smoke-updater.mjs | a real update between two locally built images |
Spillway 0.1.24