Skip to content

fix(docker): correctly pass PHP_PACKAGE_VERSION in multi-stage build - #459

Merged
ostefano merged 2 commits into
MISP:masterfrom
Diogo-Rego:fix/dockerfile-multistage-php-version-arg
Oct 8, 2026
Merged

ostefano merged 2 commits into
MISP:masterfrom
Diogo-Rego:fix/dockerfile-multistage-php-version-arg

Conversation

@Diogo-Rego

Copy link
Copy Markdown
Contributor

Fixes a multi-stage Docker build failure in core/Dockerfile where update-alternatives fails during the php-build stage.

Error:
update-alternatives: error: alternative /usr/bin/php for php not registered; not setting

Root Cause

Docker ARG variables do not automatically persist across FROM stages. Because PHP_PACKAGE_VERSION was missing in later stages, it resolved to an empty string. This broke package resolution (installing php-dev instead of a specific version) and caused the update-alternatives symlink command to fail.

Changes Made

  • Base Stage: Exported PHP_PACKAGE_VERSION and PHP_API_VERSION as ENV for better propagation.
  • Build & Final Stages: Re-declared ARG PHP_PACKAGE_VERSION (and API version) to ensure variables expand correctly for package installation and symlinks.

Comment thread core/Dockerfile Outdated
@ostefano ostefano self-assigned this Oct 8, 2026
@ostefano ostefano added the bug Something isn't working label Oct 8, 2026
@Diogo-Rego
Diogo-Rego requested a review from ostefano October 8, 2026 08:43
@ostefano
ostefano merged commit 41cdc32 into MISP:master Oct 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants