Skip to content

Replace Docker healthcheck with s6 readiness notifications#25

Merged
dash14 merged 3 commits intomainfrom
refactor/s6-readiness-notification
Mar 17, 2026
Merged

Replace Docker healthcheck with s6 readiness notifications#25
dash14 merged 3 commits intomainfrom
refactor/s6-readiness-notification

Conversation

@dash14
Copy link
Copy Markdown
Owner

@dash14 dash14 commented Mar 17, 2026

Summary

Replace Docker's healthcheck with s6 readiness notifications and manage buildkitd as an s6 service instead of the container's CMD.

Why

Docker healthcheck was insufficient for startup ordering

The previous setup used Docker's healthcheck to signal container readiness. However, this only tells Docker Compose that the container is healthy — it does not coordinate startup order within the container. buildkitd was launched as the container's CMD and could start before dnsmasq or haproxy were actually ready. While this race condition had not caused issues in practice, the startup order was not guaranteed and relied on timing rather than explicit dependency management.

buildkitd needs to wait for dependencies

buildkitd depends on dnsmasq (DNS resolution for builds), haproxy (proxy enforcement), and iptables rules (network isolation). These must all be ready before buildkitd accepts connections. s6's dependency system (dependencies.d/) enforces this ordering natively — buildkitd only starts after dnsmasq and haproxy report readiness and init-iptables completes.

s6-overlay installation was unnecessarily complex

s6-overlay was downloaded from GitHub releases via curl + tar + xz at build time, requiring architecture detection and a multi-step extraction. Alpine's apk repository already packages s6-overlay, so using apk add simplifies the Dockerfile and eliminates the pinned archive download.

Changes

  • Add buildkitd as an s6 longrun service with dependencies on dnsmasq, haproxy, and init-iptables
  • Add s6-notifyoncheck with health check scripts to dnsmasq and haproxy services for readiness notification
  • Remove CMD from Dockerfile — buildkitd is now managed by s6
  • Remove Docker healthcheck from compose.yml and setup/compose.yml
  • Remove RUN chmod — files are committed with correct permissions
  • Install s6-overlay via apk add instead of downloading from GitHub releases

dash14 added 3 commits March 17, 2026 21:26
Docker's healthcheck polling was used to determine when services were ready. s6-notifyoncheck provides the same readiness detection but integrates natively with the s6 supervision tree, enabling proper dependency ordering between services (e.g. buildkitd waits for dnsmasq and haproxy) without external polling.
The manual download (curl + tar + xz) added build complexity and pinned to a specific release archive. Alpine's apk repository already packages s6-overlay, so using it simplifies the Dockerfile and delegates version management to the base image's package index.
@dash14 dash14 force-pushed the refactor/s6-readiness-notification branch from 872cd61 to 43ae83b Compare March 17, 2026 12:55
@dash14 dash14 merged commit f05d522 into main Mar 17, 2026
6 checks passed
@dash14 dash14 deleted the refactor/s6-readiness-notification branch March 17, 2026 12:58
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