how-to deployer

Runbook — the offline page (host service)

In plain language. When a country’s website is unreachable, its visitors should see a designed “please wait” screen, not a raw browser error. Until now that screen was served by a small helper running inside the same stack as the main application — so the moment a deploy restarted the application, the helper went down with it, and visitors saw the reverse proxy’s bare error text instead. This runbook covers the fix: the screen now runs as its own service on the machine itself, independent of the application, so it keeps answering exactly when it is needed most.

Status: code complete (#2686); not yet installed on the sandbox. Run the installer there (below) before removing the old in-app copy. Spec / design: owner-settled design on issue #2686. Scope: any deployment host. Each country installs its own copy.


What changed and why

The offline page is deploy/error-page/unavailable.html — a single, self-contained HTML file. A reverse proxy (Traefik) is configured to show it whenever the main application answers with a 502/503/504 error, i.e. while it is restarting or unreachable.

Previously, the page was served by the errorpage service declared inside the application’s own docker-compose.yml stack. A redeploy of the application tears down every service in that stack, the errorpage service included — so the one moment the page needed to be up (a redeploy in progress) was the one moment it was guaranteed to be down.

The fix moves the page to a host systemd service (deploy/error-page/opengov-offline-page.service) — a small, pinned nginx container that systemd supervises directly, outside any compose stack a redeploy could tear down. The same pattern already exists for the image registry (docs/runbooks/registry.md) and is documented as the standing convention in docs/reference/deployment-architecture.md §7.

Installing it on a deployment host

cd <the deployment's own checkout>
sudo bash scripts/install-offline-page.sh

This renders the page and its Traefik route from the deployment’s own committed deployments/<code>/config.yaml (country wordmark and emblem baked in as an inline image — nothing is fetched during an outage), installs and starts the systemd unit, copies the rendered Traefik route to /data/coolify/proxy/dynamic/ (hot-reloads, no proxy restart needed), and proves the page answers on its probe route before reporting success. An installer that reports success without checking this is how a host ends up believing it has an offline page during the exact outage it exists for.

The rendered route covers the 5 SPA hosts only — not mcp.<base> (an assistant expects a JSON error from a down deployment, not an HTML screen) and not login.<base> (a separate container, Keycloak, that this page has no bearing on).

The container joins the persistent proxy network — the one Coolify’s Traefik itself is on, with no com.docker.compose.project label — rather than the application’s own compose-created network. That distinction is the whole point: the compose network is removed every time docker compose down runs, which is exactly the moment this page must still be answering. The installer resolves it from the proxy container’s own networks intersected with the app’s (scripts/lib/offline_page_network.sh), never from a name-prefix guess. OPENGOV_PROXY_CONTAINER names the proxy container to inspect (default coolify-proxy); OPENGOV_PROXY_NETWORK skips resolution and names the network directly. Set OPENGOV_PROXY_NETWORK once per host if this installer’s resolution ever disagrees with what Traefik is actually on — cheaper than debugging the intersection on every future re-run.

A missing or oversized emblem file fails this step loudly rather than shipping silently: a missing file is caught at artifact load (before rendering starts); an oversized one is capped at the same 512 KB the live app’s boot-time upload enforces. Either way set -euo pipefail aborts the install with the error printed — fix the artifact and re-run.

Re-run it any time config.yaml’s branding or hostnames change, or to pick up a change to the unit itself — it is idempotent.

Verify from anywhere:

curl -sI https://<any SPA host>/__edge__/offline   # 200, X-Opengov-Edge: error-pages-v1

The honest limit

If the container engine (Docker) itself is down on the host, there is no proxy and no page. This service protects against the application being redeployed, crashed, or otherwise unreachable — not against the whole host going dark. Nothing can serve a page from a host that cannot run containers.

Removing the old in-app copy

The errorpage service stays in docker-compose.yml, commented as superseded, until the host service above is confirmed serving on the sandbox. Once that is verified:

  1. Confirm curl -sI https://<any SPA host>/__edge__/offline answers 200 with the marker header.
  2. Remove the errorpage service block from docker-compose.yml (a separate PR — see the comment above the block for the “why now” note).

Smoke-testing it

scripts/smoke_deployment.py --check-offline-page adds two checks: the probe route answers through the proxy on every SPA hostname (not just one — a route file missing one host’s probe router must fail here), and the rendered Traefik route names every SPA hostname the artifact declares. It is opt-in — a deployment that has not yet run the installer above would otherwise fail smoke on this alone. Pass the flag once the installer has run.