microsoft / microsoft/vscode-remote-release

Non-Buildkit: Builds stages past the one specified in `build.target`

Open
#8,085 1 comment 0 reactions 1 assignee View on GitHub

@chrmarti is already working on this.

Since Feb 23, 2023.

bug containers
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:

  1. A temporary Dockerfile (/tmp/devcontainercli-user/container-features/0.29.0-1677056454540/Dockerfile-with-features) was created that is

    ARG _DEV_CONTAINERS_BASE_IMAGE=placeholder
    <the content of the actual dockerfile>
    FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage
    LABEL devcontainer.metadata=…
    
  2. and while docker build --target will stop at the specified target stage, it will not skip the stages that don't contribute to the target because it simply processes the Dockerfile sequentially.

  3. Note that the docker provided by rancher desktop does not have buildx command. But I don't think it would actually make a difference.

This is a problem because

  1. 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.
  2. 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:

  1. Configure a project with multi-stage Dockerfile in the style that Visual Studio generates for .net projects. That is with at least these three stages:
  • FROM public-image as builder with the toolchain setup
  • FROM builder as build where the project is built and
  • FROM different-image as release where the built artifact is copied --from=build
  1. Configure devcontainer with
  "build": {
    "dockerfile": "../Dockerfile",
    "context": "..",
    "target": "build"
  }
  1. Now open in the devcontainer. The build will run the stages build and release. It shouldn't.

Does this issue occur when you try this locally?: N/A – container build

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.