microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 292 forks source link

Buildkit support at devcontainer.json level #1409

Closed darkvertex closed 1 year ago

darkvertex commented 5 years ago

This is technically a dupe of https://github.com/microsoft/vscode-remote-release/issues/87 but since the other issue was closed and further commenting disallowed, I could not continue there.

Buildkit is great and very useful and right now if my Dockerfile absolutely needs it to build, it's great that I can control the runArgs in the devcontainer.json but it won't set DOCKER_BUILDKIT=1 for me at build time, so I need to remember to export that env var prior to launching vscode or my dev container won't build. It's not very ergonomic.

I found this doc page that suggests adding env vars by modifying the runArgs but from what I can tell that's only good for passing env vars to docker run, not setting them for docker build: https://code.visualstudio.com/docs/remote/containers-advanced#_adding-environment-variables

In the devcontainer.json, I would love either:

a) "use_buildkit": true or similar. b) or something to set the env for the docker build call, maybe:

"buildEnv": {
  "DOCKER_BUILDKIT": "1"
}

Thoughts?

aguckenber-chwy commented 1 year ago

We use buildx build by default and fall back to build when buildx is not installed. docker-compose v2 appears to use buildx build in its recent versions.

@Aposhian Not currently. Support for build CLI options is tracked as #3545.

Is there anything you were looking for getting from using BuildKit that would not be covered by adding build CLI options (#3545)? (Trying to find out if we can close this issue.)

Really need this issue. Trying to use these variables which are only in the newer buildkit. https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope

Would be nice to be able to overwrite the build command that is run or something just to get around hurdles like these.

chrmarti commented 1 year ago

@aguckenber-chwy See https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope.

We use BuildKit automatically if it is available (which seems to become the default with newer installations). That should make a flag in the devcontainer.json unnecessary and I will close this issue. Please open new issues for other BuildKit-related requests/bugs. Thanks!