Skip to content

Feat(docker): the image reports its own health (#49) - #68

Merged
adibhanna merged 2 commits into
mainfrom
feat/healthcheck-49
Nov 4, 2026
Merged

adibhanna merged 2 commits into
mainfrom
feat/healthcheck-49

Conversation

@adibhanna

Copy link
Copy Markdown
Contributor

For #49. The issue stays open until this is merged, then it gets its own comment and close.

The image is FROM scratch, so a Compose healthcheck had nothing to run. This adds zennotes-server healthcheck, which calls /healthz on the server already running in the container, using the same bind and base path, and exits 0 or 1. The Dockerfile's HEALTHCHECK runs it, with the timings proposed in the issue, and the README's Docker section now describes it. A pass means the server is answering, not that the vault is readable.

Run against a real arm64 image:

  • The HEALTHCHECK is on the image, and the container reads healthy with an auth token set.
  • With ZENNOTES_BASE_PATH=/zen it reads healthy. /zen/healthz answers 200 and /healthz answers 404, so the probe uses the base path.
  • With loopback taken down and the server still running, it reads unhealthy, then healthy again once loopback returns.
  • With the server hung by SIGSTOP, it reads unhealthy once the 3s probe timeout hits.
  • In Compose, both the image default and the README's YAML read healthy, and depends_on: service_healthy holds a dependent service back until they do.
  • healthcheck now only probes and exits 1 when nothing is listening. It does not start a second server.

go vet ./..., go test ./... and the CI nix build pass locally. No amd64 image was run; CI builds it.

The image is FROM scratch, so a Compose healthcheck has no shell, wget or
curl to run, and self-hosters on Compose-based platforms had no health
status without customizing the image.

`zennotes-server healthcheck` asks the server already running in the
container for /healthz, using the same bind and base path, and exits 0 or 1.
It ignores any HTTP proxy and follows no redirects, so only the server's own
200 counts. The Dockerfile's HEALTHCHECK runs it, using the timings lewxdev
proposed in the issue. It means the server is answering, not that the vault
is readable.
…oxies (#49)

A review of this branch found three ways the new probe misled Docker.

A [::] bind called ::1, which does not exist where IPv6 is off, so a working
server read unhealthy and Traefik kept the site at 404. Go's [::] listener
also takes IPv4, so every wildcard now calls 127.0.0.1.

The URL was concatenated, so a base path the server accepts, like /100%,
failed to parse and read unhealthy for good. It is now built with url.URL.

A proxy that reads Docker health routes nothing until the first probe, which
took 5s on current Docker. --start-interval=1s brings that to about 1s; Docker
24 ignores it and stays at 30s, as before. The README now says so and shows
the opt-out.
@adibhanna
adibhanna merged commit 0318fd3 into main Nov 4, 2026
10 checks passed
@adibhanna
adibhanna deleted the feat/healthcheck-49 branch November 4, 2026 18:05
@adibhanna adibhanna mentioned this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant