Skip to content

dev_container: Resolve compose service build args in Dockerfile expansion#54270

Merged
KyleBarton merged 3 commits intozed-industries:mainfrom
fechu:fix-devcontainer-compose-build-args
Apr 21, 2026
Merged

dev_container: Resolve compose service build args in Dockerfile expansion#54270
KyleBarton merged 3 commits intozed-industries:mainfrom
fechu:fix-devcontainer-compose-build-args

Conversation

@fechu
Copy link
Copy Markdown
Contributor

@fechu fechu commented Apr 19, 2026

For docker-compose-based dev containers, build args live on the primary compose service's build.args, not on dev_container.build (which is None in the compose case). expanded_dockerfile_content only consulted the latter, so ${…} references in the service's Dockerfile — e.g. FROM ${BASE_IMAGE} — were never substituted. Downstream callers then invoked docker inspect "${BASE_IMAGE}" and docker pull "${BASE_IMAGE}", both of which fail and the dev container fails to start.

A new unit test test_expands_compose_service_args_in_dockerfile mounts a Dockerfile with FROM ${BASE_IMAGE} backed by a compose service whose build.args define BASE_IMAGE=test_image:latest, and asserts both expanded_dockerfile_content and image_from_dockerfile produce the resolved reference.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed dev container startup failing for docker-compose configs whose service Dockerfile uses build-arg substitution in the FROM line (for example, FROM ${BASE_IMAGE}).

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 19, 2026
…sion

For docker-compose devcontainers, build args live on the primary compose
service's `build.args`, not on `dev_container.build` (which is `None`).
`expanded_dockerfile_content` only looked at the latter, so `${…}`
references in the service's Dockerfile (e.g. `FROM ${BASE_IMAGE}`) were
never substituted. Downstream callers then invoked `docker inspect
"${BASE_IMAGE}"` and `docker pull "${BASE_IMAGE}"`, both of which fail.

Dispatch on `build_type` and pull the args from the correct source.

Release Notes:

- Fixed dev container startup failing for docker-compose configs whose service Dockerfile uses build-arg substitution in the FROM line (for example, \`FROM \${BASE_IMAGE}\`).
@fechu fechu force-pushed the fix-devcontainer-compose-build-args branch from a564075 to 764491f Compare April 19, 2026 22:42
@fechu fechu marked this pull request as ready for review April 19, 2026 22:43
@KyleBarton KyleBarton self-requested a review April 21, 2026 23:36
Copy link
Copy Markdown
Collaborator

@KyleBarton KyleBarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@KyleBarton KyleBarton merged commit bcaa1b5 into zed-industries:main Apr 21, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants