dev_container: Fix various startup issues#53170
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @zdeneklapes on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Hey @zdeneklapes thanks for the fixes! I'm just a user here, who encountered similar problems, and I'm now taking the Dockerfile path resolution fixes to use in the build I use for daily work. However, I extracted the fix to only that problem in a dedicated branch, as I did not have time to check the other things and I don't want to have extra risks. I opened a PR with just the Dockerfile path fix too, #53860 The zed devs will decide what to do with the fixes, I'm just mentioning for info. |
…ext (#53860) ## Context When a Docker Compose service specifies `context: ..` and `dockerfile: .devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to the compose file's directory instead of the build context. This produces a doubled path like `.devcontainer/.devcontainer/Dockerfile` which doesn't exist. Per the [Docker Compose spec](https://docs.docker.com/reference/compose-file/build/#dockerfile), the `dockerfile` field is relative to the build context directory. The fix resolves the context directory first (relative to the compose file), then joins the dockerfile path to that. Closes #53473 ## Prior art This fix is extracted from #53170 by @zdeneklapes, which addresses this bug among several other dev container startup issues. This PR isolates the dockerfile path resolution fix into a focused change to make it easier to review and merge independently. Differences from #53170: - **Scope**: Only the dockerfile-relative-to-context fix, not the other fixes (compose build args preservation, remote user fallback, Docker inspect labels, etc.) - **Implementation**: Inline resolution in `dockerfile_location()` rather than separate helper methods - **Absolute path handling**: Handles absolute dockerfile and context paths - **Tests**: Two test cases — compose file inside `.devcontainer/` with `context: ..`, and compose file at project root with `context: .` ## How to Review Single file change in `crates/dev_container/src/devcontainer_manifest.rs`: - **Fix** (line 234-252): Resolve build context relative to compose file directory, then join dockerfile to that, instead of joining dockerfile to `config_directory` directly. Uses `normalize_path` to resolve `..` components. - **Tests**: Two new `FakeDocker` compose config entries and corresponding tests asserting correct resolved paths. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed docker-compose `dockerfile` path being resolved relative to the compose file instead of the build `context` directory. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ext (zed-industries#53860) ## Context When a Docker Compose service specifies `context: ..` and `dockerfile: .devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to the compose file's directory instead of the build context. This produces a doubled path like `.devcontainer/.devcontainer/Dockerfile` which doesn't exist. Per the [Docker Compose spec](https://docs.docker.com/reference/compose-file/build/#dockerfile), the `dockerfile` field is relative to the build context directory. The fix resolves the context directory first (relative to the compose file), then joins the dockerfile path to that. Closes zed-industries#53473 ## Prior art This fix is extracted from zed-industries#53170 by @zdeneklapes, which addresses this bug among several other dev container startup issues. This PR isolates the dockerfile path resolution fix into a focused change to make it easier to review and merge independently. Differences from zed-industries#53170: - **Scope**: Only the dockerfile-relative-to-context fix, not the other fixes (compose build args preservation, remote user fallback, Docker inspect labels, etc.) - **Implementation**: Inline resolution in `dockerfile_location()` rather than separate helper methods - **Absolute path handling**: Handles absolute dockerfile and context paths - **Tests**: Two test cases — compose file inside `.devcontainer/` with `context: ..`, and compose file at project root with `context: .` ## How to Review Single file change in `crates/dev_container/src/devcontainer_manifest.rs`: - **Fix** (line 234-252): Resolve build context relative to compose file directory, then join dockerfile to that, instead of joining dockerfile to `config_directory` directly. Uses `normalize_path` to resolve `..` components. - **Tests**: Two new `FakeDocker` compose config entries and corresponding tests asserting correct resolved paths. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed docker-compose `dockerfile` path being resolved relative to the compose file instead of the build `context` directory. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ext (zed-industries#53860) ## Context When a Docker Compose service specifies `context: ..` and `dockerfile: .devcontainer/Dockerfile`, Zed resolves the dockerfile path relative to the compose file's directory instead of the build context. This produces a doubled path like `.devcontainer/.devcontainer/Dockerfile` which doesn't exist. Per the [Docker Compose spec](https://docs.docker.com/reference/compose-file/build/#dockerfile), the `dockerfile` field is relative to the build context directory. The fix resolves the context directory first (relative to the compose file), then joins the dockerfile path to that. Closes zed-industries#53473 ## Prior art This fix is extracted from zed-industries#53170 by @zdeneklapes, which addresses this bug among several other dev container startup issues. This PR isolates the dockerfile path resolution fix into a focused change to make it easier to review and merge independently. Differences from zed-industries#53170: - **Scope**: Only the dockerfile-relative-to-context fix, not the other fixes (compose build args preservation, remote user fallback, Docker inspect labels, etc.) - **Implementation**: Inline resolution in `dockerfile_location()` rather than separate helper methods - **Absolute path handling**: Handles absolute dockerfile and context paths - **Tests**: Two test cases — compose file inside `.devcontainer/` with `context: ..`, and compose file at project root with `context: .` ## How to Review Single file change in `crates/dev_container/src/devcontainer_manifest.rs`: - **Fix** (line 234-252): Resolve build context relative to compose file directory, then join dockerfile to that, instead of joining dockerfile to `config_directory` directly. Uses `normalize_path` to resolve `..` components. - **Tests**: Two new `FakeDocker` compose config entries and corresponding tests asserting correct resolved paths. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed docker-compose `dockerfile` path being resolved relative to the compose file instead of the build `context` directory. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
This merge request fixes multiple dev-container startup issues.
It improves Docker Compose path resolution, preserves compose build configuration when generating
feature builds, hardens remote user detection, and fixes Docker inspect parsing for images that omit
Config.Labels. Together, these changes make dev containers more reliable across a wider range of
setups, including plain base images such as debian:bookworm-slim.
Per-Commit Breakdown
This commit contains the main dev-container fixes.
handling.
This commit fixes startup for images whose docker inspect output does not include Config.Labels.
Why These Changes Were Needed
Dev container startup was failing in several valid configurations:
These changes make the implementation more tolerant of real-world Docker and Compose outputs while keeping the existing dev-container flow intact.
Release Notes
layouts and for images whose docker inspect output omits Config.Labels