Skip to content

build: add support for Docker healthchecks in image configuration - #2705

Open
makaiver wants to merge 3 commits into
chainguard-dev:mainfrom
makaiver:image-healthcheck
Open

makaiver wants to merge 3 commits into
chainguard-dev:mainfrom
makaiver:image-healthcheck

Conversation

@makaiver

Copy link
Copy Markdown

Summary

Add an optional healthcheck block to apko.yaml so users can package a default Docker health probe with the image. It supports exec (CMD) and shell (CMD-SHELL) probes, with configurable interval, timeout, start period, and retries.

healthcheck:
  test: ["CMD", "/usr/bin/my-service", "healthcheck"]
  interval: 30s
  timeout: 5s
  start-period: 10s
  retries: 3

Omitting the block preserves any inherited probe. Use test: ["NONE"] to disable a probe from an included config.

Testing

  • Verified exec and shell probes locally with Docker.
  • The full Go race suite and lint passed.

Expose an optional healthcheck block in apko YAML so runtime probes travel with the image. Validate test modes and timing values and serialize the check through the existing image writer.

Document runtime compatibility and cover include precedence, validation, and config generation.
Validate retry counts before YAML decoding can truncate them. Reject nonzero durations that parse as zero and NUL bytes in probe commands. Cover these cases with regression tests.
Reject null YAML sequence entries before decoding the command into strings. This preserves argument positions and reports the offending index for nulls and aliases to null.
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