Skip to content

fix: HEALTHCHECK detection respects dockerfile_target_build in multi-stage Dockerfiles#9477

Open
jeongkichang wants to merge 2 commits intocoollabsio:nextfrom
jeongkichang:fix/healthcheck-multistage-detection
Open

fix: HEALTHCHECK detection respects dockerfile_target_build in multi-stage Dockerfiles#9477
jeongkichang wants to merge 2 commits intocoollabsio:nextfrom
jeongkichang:fix/healthcheck-multistage-detection

Conversation

@jeongkichang
Copy link
Copy Markdown

Changes

When using multi-stage Dockerfiles with dockerfile_target_build, parseHealthcheckFromDockerfile searched the entire Dockerfile text for "HEALTHCHECK" regardless of target stage. This caused incorrect healthcheck configuration from other stages to be applied.

  • Added extractTargetStageLines() to Application.php that parses FROM ... AS <stage> boundaries and returns only lines within the target stage
  • When dockerfile_target_build is not set, falls back to original behavior (all lines)
  • Added HEALTHCHECK NONE handling — returns early without applying any healthcheck config
  • Added 6 unit tests for multi-stage HEALTHCHECK detection

Issues

Category

  • Bug fix
  • Improvement
  • New feature
  • Adding new one click service
  • Fixing or updating existing one click service

Preview

N/A — backend logic change, no UI changes.

AI Assistance

  • AI was used (please describe below)

If AI was used:

  • Tools used: Claude Code (code review, test generation)
  • How extensively: AI assisted with test case generation and code review. Core logic was human-designed based on source code analysis.

Testing

./vendor/bin/pest tests/Unit/ApplicationHealthcheckMultiStageTest.php
# 6 passed (11 assertions)

./vendor/bin/pest tests/Unit/ApplicationHealthcheckRemovalTest.php
# 3 passed (7 assertions) — existing tests unaffected

Tested scenarios:

  1. Target stage api with HEALTHCHECK → detected correctly
  2. Target stage worker without HEALTHCHECK → not detected (fixed behavior)
  3. No target stage set → falls back to all lines (backward compatible)
  4. HEALTHCHECK NONE in target stage → treated as explicit disable
  5. Case-insensitive stage name matching
  6. Non-existent target stage → falls back to all lines

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate.
  • I have tested all the changes thoroughly with a local development instance of Coolify and I am confident that they will work as expected when a maintainer tests them.

andrasbacsai and others added 2 commits April 5, 2026 16:20
…stage Dockerfiles

When using multi-stage Dockerfiles with dockerfile_target_build,
parseHealthcheckFromDockerfile now only searches for HEALTHCHECK within
the target stage instead of the entire Dockerfile text.

Also adds HEALTHCHECK NONE handling per Docker specification.

Fixes coollabsio#9475
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.

2 participants