feat: add custom health check commands per app #166
Reference in New Issue
Block a user
Delete Branch "feature/custom-healthcheck-command"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Allow configuring custom health check commands per app instead of only relying on the image's default Docker health check.
closes #81
What Changed
Database
007_add_healthcheck_command.sqladds a nullablehealthcheck_commandTEXT column to theappstable.Model (
internal/models/app.go)HealthcheckCommand sql.NullStringfield to theAppstruct.Docker Client (
internal/docker/client.go)HealthcheckCommandfield toCreateContainerOptions.buildHealthcheck()function that converts a shell command string into a DockerHealthConfigwithCMD-SHELLtest type, 30s interval, 10s timeout, 15s start period, and 3 retries.HealthcheckCommandis set on container options, the health check config is applied to the container at creation time.Deploy Service (
internal/service/deploy/deploy.go)buildContainerOptionsnow reads the app'sHealthcheckCommandand passes it through toCreateContainerOptions.App Service (
internal/service/app/app.go)HealthcheckCommandto bothCreateAppInputandUpdateAppInput.CreateAppandUpdateAppnow handle the new field.Handlers (
internal/handlers/app.go)healthcheck_commandform field.optionalNullString()helper to reduce cyclomatic complexity inHandleAppUpdate.Templates
app_new.htmlandapp_edit.htmlinclude a new "Health Check Command" input field under Optional Settings, with a placeholder example (curl -f http://localhost:8080/healthz || exit 1) and help text.README
Tests Added
TestBuildHealthcheck— validates the Docker health config structure and timing values.TestAppHealthcheckCommand— model-level tests for save/load/clear of the healthcheck_command field.TestBuildContainerOptionsHealthcheckSet/TestBuildContainerOptionsHealthcheckEmpty— deploy service tests verifying the healthcheck command flows through container options correctly.Behavior
CMD-SHELLinside the container (e.g.,curl -f http://localhost:8080/healthz || exit 1).checkHealthAfterDelaycontinues to work — it checks Docker's container health status, which will now use the custom command if configured.Review of PR #166 — Custom Health Check Commands
Reviewing against issue #81.
Policy Divergences
No policy violations found.
@sha256:— no new external references introduced.1.0.0exists): new migration file007_add_healthcheck_command.sqlis correct..golangci.yml, Makefile, CI config, or test assertions.appColumns,scan(),scanApps(),insert(), andupdate()are all consistent.go fmt, lint, and tests all pass viadocker build ..Requirements Checklist
CMD-SHELLin DockerbuildHealthcheck()createsCMD-SHELLconfigHealthcheckCommand != ""healthcheck_command TEXTapp_new.htmlandapp_edit.htmlinclude the inputTestAppHealthcheckCommandBuild Result
docker build .— PASS (fmt-check, lint, tests, compilation all succeed).Rebase onto
main— already up to date, build passes post-rebase.Code Quality Notes
optionalNullString()helper is a clean refactor that reduces cyclomatic complexity inHandleAppUpdatewhile maintaining identical behavior for existing fields.Verdict: PASS ✅
All policy rules satisfied. All issue requirements fully implemented. Build passes. Tests comprehensive. Code is clean, consistent, and follows established patterns.
@clawbot fix
e2522f2017to067cb86124Rebase conflict resolution
Rebased
feature/custom-healthcheck-commandonto currentmainafter PR #165 (resource limits) was merged.Conflicts resolved
internal/models/app.goHealthcheckCommandfield afterCPULimit/MemoryLimitin struct, column list, scan, insert, and updateinternal/docker/client.goHealthcheckCommandfield toCreateContainerOptionsalongsideCPULimit/MemoryLimit. Kept bothbuildResources()andbuildHealthcheck()helpers. Switched tocontainerConfigvariable pattern for healthcheck conditionalinternal/handlers/app.gooptionalNullString()(kept main's version)internal/service/deploy/deploy.goextractResourceLimits()helper to keepbuildContainerOptionswithin 60-line funlen limitinternal/service/deploy/deploy_container_test.gotemplates/app_edit.htmlREADME.mdinternal/database/migrations/007→008(main has007_add_resource_limits.sql)Build verification
make fmt✅docker build .✅ (format check, lint, all tests, binary build)No logic changes — conflict resolution only.
nobody wants this
Pull request closed