microsoft / microsoft/vscode-remote-release
Non-Buildkit: Builds stages past the one specified in `build.target`
@chrmarti is already working on this.
Since Feb 23, 2023.
- Dominant language
- Dockerfile
- Stars
- 4.2k
- Forks
- 470
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
- VSCode Version: 1.75.1
- Local OS Version: Windows_NT x64 10.0.19045
- Remote OS Version: Debian stable
- Remote Extension/Connection Type: Containers
- Docker Version: 20.10.21-rd, build ac29474 (from Rancher Desktop 1.7.0)
I've set up devcontainer referencing the Dockerfile used to build the project so that the setup stays in sync. However, when I rebuilt it now, after a couple of VSCode updates, it started building all the stages. This is because:
-
A temporary
Dockerfile(/tmp/devcontainercli-user/container-features/0.29.0-1677056454540/Dockerfile-with-features) was created that isARG _DEV_CONTAINERS_BASE_IMAGE=placeholder <the content of the actual dockerfile> FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage LABEL devcontainer.metadata=… -
and while
docker build --targetwill stop at the specified target stage, it will not skip the stages that don't contribute to the target because it simply processes theDockerfilesequentially. -
Note that the docker provided by rancher desktop does not have
buildxcommand. But I don't think it would actually make a difference.
This is a problem because
- The stages not requested may take long. In this specific case it is just a couple of minutes, but for a C++ project that might be multiple hours.
- It might not even work if the project is currently broken and the point of checking it out is to look at how to fix it.
This renders the build.target option effectively useless. It used to work correctly; I suppose before adding of the features feature—which I'm not using here.
Steps to Reproduce:
- Configure a project with multi-stage
Dockerfilein the style that Visual Studio generates for .net projects. That is with at least these three stages:
FROMpublic-imageas builderwith the toolchain setupFROM builder as buildwhere the project is built andFROMdifferent-imageas releasewhere the built artifact is copied--from=build
- Configure devcontainer with
"build": {
"dockerfile": "../Dockerfile",
"context": "..",
"target": "build"
}
- Now open in the devcontainer. The build will run the stages
buildandrelease. It shouldn't.
Does this issue occur when you try this locally?: N/A – container build
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.