Skip to main content
Run Hatchmark next to your data. One container rebuilds the dashboards on a schedule and serves the last good build to your colleagues. It runs inside your own network, beside the database, so the database never has to be reachable from the internet.
That is the whole setup: hatchmark serve builds at once, then every day at 6 AM New York time, and serves the dashboards at http://<host>:8080/. Pin the image to a version tag rather than latest, so a rebuild never changes Hatchmark under you.

The image

Every Hatchmark release publishes ghcr.io/hatchmark-dev/hatchmark for linux/amd64 and linux/arm64, so one tag runs on x86 servers and on ARM hosts such as AWS Graviton or Apple silicon.
A prerelease such as 1.5.0-rc.1 gets only its own version tag, and a patch to an older line, such as 1.3.9 after 1.4.0, never moves latest. Each image carries its SBOM and build provenance:

Why it runs inside your network

Production databases usually sit in a private network, and a build has to read them. A build on a hosted CI runner or a laptop can’t reach them, so the build runs on a machine that can: a VM, a Kubernetes cluster or any container host in the same network as the database. The pages it serves hold only aggregated results, never a connection to the database.

The project

Mount the project directory (the one with hatchmark.yaml) at /project, read-only. Before each build, serve copies it into its state directory, so a build always sees one consistent version of the project even while it changes. To ship an edit, update the directory with git pull on the host, a deploy job, or a git-sync sidecar in Kubernetes. The next build picks it up.

Secrets

hatchmark.yaml names environment variables and never holds a connection string (see database sources). Give the container those variables, for example with an env file that only the deploy user can read:
In Kubernetes, put them in a Secret and pass it with envFrom. Use a database user that can only read. The image includes the database and cloud storage extensions Hatchmark uses (PostgreSQL, MySQL, SQLite, S3, GCS and Azure, and SQL Server where available), so builds need no internet access to fetch them.

Schedules

serve always builds once at start. It never runs two builds at once: a build that overruns its interval is followed by the next one straight away. A query that hangs is stopped at the timeout, so it can’t hold up the builds after it. The default timeout follows your builds: twice the slowest of the last 20 good builds, and at least the interval up to one hour. Until a build has succeeded it is one hour, since the first build fills the cache and is the slowest. A project whose data grows gets a longer timeout as its builds slow down, without a setting. Frequent builds stay cheap. Each one reuses the results of queries whose inputs didn’t change (the build cache), and a database source reuses its local copy while it is younger than its max_age. Match max_age to how often the table really changes: a table loaded once a night needs max_age: { hours: 12 } even when the dashboards build every hour. The cache lives in the state directory, so it survives restarts.

When a build fails

The last good build keeps being served. A failed build never replaces it. Every page footer shows when its data was updated. A page calls its data late, and shows a banner saying it may be out of date and since when, only when a build has started and neither it nor any later build has succeeded by its start plus its timeout plus a grace period. The grace period is a tenth of the interval between scheduled builds, at least 15 minutes: 15 minutes for hourly builds, 2 hours 24 minutes for a daily one. So a build that is still running is never late, a slow build that finishes inside its window raises nothing, and a failed build that the next one fixes in time raises nothing either. A page that stays open while a newer build replaces it says newer data is available and offers a reload, rather than claiming the new update time for the numbers it shows.
  • Each build logs one JSON line to stdout (docker logs hatchmark) with its result, duration, cache reuse and, for a failure, the full diagnostics.
  • /status shows the last 20 builds with their error codes, and stale turns true at the same moment the banner appears.
  • A webhook can tell you, see below.
Until the first build succeeds, viewers see a “not ready yet” page with status 503. The reason is only in the logs, because diagnostics can name tables and columns.

Webhook

Set HATCHMARK_WEBHOOK_URL to an http or https URL and serve POSTs JSON to it when the data turns late, by the same rule as the banner, and again when a build succeeds after that. A database that stays down for a night sends one message, not twelve, and a single failed build that the next one fixes sends none. The late time and whether the alert went out are kept in the state directory, so a restart during an outage neither moves the deadline nor sends the alert again.
event is data.late or data.recovered. last_run.codes are the diagnostic codes (hatchmark explain HM2041 explains one), and the payload never includes diagnostic messages, which can name tables and columns, or any secret. Anything that accepts a JSON POST can receive it. Tools that read a text field, such as a Slack incoming webhook, show the sentence as is; for others, forward the payload with your own automation. serve tries three times over about half a minute and logs the result, never the URL.

Health checks

Neither JSON route holds diagnostic messages; they are only in the logs. The image’s Docker health check calls /healthz on port 8080. Failed builds never make /healthz fail: restarting the container can’t fix a database that is down, and the last good build should keep being served meanwhile. Alert on stale in /status or on the webhook instead. Pages that were served before a new build replaced the old one keep loading their scripts and fonts: serve keeps the content-hashed files of earlier builds for seven days.

Who can see the dashboards

serve has no login of its own, and every page holds the numbers it shows. Keep it on your private network, or put it behind the access control you already use: a VPN such as Tailscale, or a sign-in proxy such as Cloudflare Access or oauth2-proxy in front of it. If you’d rather not run that yourself, use the hosted version of Hatchmark. The API at /api/v1 shows what the pages show, so the same access control covers it, and your apps call it with the viewer’s sign-in. /embed/v1 is for servers outside that access control: it answers only requests with a token, like /mcp, so exempt /embed/v1 and the paths under it the same way, and nothing else under /embed/ (see behind a sign-in proxy).

Agents over MCP

serve can also answer AI agents, such as Claude Code or Codex, on the same port at /mcp: the same four read-only tools as hatchmark mcp (see CLI), over MCP’s Streamable HTTP transport. It stays off until you give it tokens. Put one named token per person or agent in HATCHMARK_TOKENS, comma separated:
The same tokens open the API at /embed/v1. serve still reads HATCHMARK_MCP_TOKENS when HATCHMARK_TOKENS isn’t set. Generate each token with openssl rand -hex 32; serve refuses a token shorter than 32 characters or with characters a bearer token can’t carry (only letters, digits and - . _ ~ + /, with = at the end), a name used twice, and a token shared by two names. A request needs Authorization: Bearer <token>; any other gets 401. serve logs one mcp line per request with the token’s name, never the token, so the log shows who asked. Browser requests from any origin but localhost get 403. Hatchmark MCP only reads and never changes data: each tool is marked read-only and non-destructive for the client. Queries run in the container, against the sources, read-only and one at a time, with the same result limits as hatchmark mcp. To connect Claude Code:
Rotating a token. Tokens are read at start. Add the new one under a new name, such as alice2=<new>, restart, move the client to it, then remove alice=<old> and restart again. Removing a name revokes its token at the next restart; nothing else changes. Behind a sign-in proxy. A sign-in proxy such as Cloudflare Access or oauth2-proxy can’t sign in an agent, so exempt /mcp from it and let the token protect that path. With oauth2-proxy, that’s --skip-auth-route=^/mcp$. In Cloudflare Access, add a Bypass policy for the /mcp path, and keep /mcp on HTTPS. Exempt /embed/v1 and the paths under it the same way (--skip-auth-route=^/embed/v1(/|$)) when servers outside call the API; other paths under /embed/ are ordinary pages and stay behind the proxy.

Docker Compose

hatchmark init writes this compose.yaml into the project, with the image pinned to the version that wrote it and --tz set to the project’s timezone, and a starting hatchmark.env.example. Copy the example to hatchmark.env, add a line for each variable your sources name, and start it from the project directory:
init adds hatchmark.env to .gitignore, and serve leaves it out of the copy it builds from.
For agents over MCP, add the tokens to hatchmark.env:

Kubernetes

Run one replica: each instance builds on its own schedule. Any way of getting the project into /project works, such as a volume a deploy job writes or a git-sync sidecar.

Serving the files yourself

To publish with a web server you already run, or to sync to object storage behind a CDN, add --out <dir>: serve also writes each good build there with its _hatchmark/status.json, and updates that file after a failed build, so the footer and the banner work there too. Files there are replaced in place, as with hatchmark build --out: if a write fails partway, serve logs it, the directory can mix two builds until the next good one is written, and serve itself keeps serving and building from its own complete copy. Plain hatchmark build writes static pages with neither an update time nor a banner.

Without Docker

hatchmark serve runs the same way wherever Hatchmark is installed. Its state directory defaults to .hatchmark/serve in the project; --state-dir or HATCHMARK_STATE_DIR moves it outside. HATCHMARK_STATE_DIR also holds the build cache and database copies of every other command. Run it under a process manager such as systemd, and stop it with SIGTERM: it stops the build in progress and exits.