vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

devcontainer.json cannot use exported vars from initializeCommand

Open bence42 opened this issue 3 years ago • 1 comments
trafficstars

Version: 1.69.2 (user setup) Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a Date: 2022-07-18T16:12:52.460Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19044

The initializeCommand is advertised to run as the very first step, but it cannot be used to have any meaningful effect on the devcontainer.json itself. For example none of the following is possible:

  • setting the "name" property from initializeCommand
  • setting the FROM argument of a Dockerfile by passing a build-arg that's exported by initializeCommand
  • changing proxy settings on a user by user basis via initializeCommand
  • changing any setting in the devcontainer.json
  • rolling out docker image version updates without having to tinker with the vscode devcontainer settings

We use several docker images in production and we use them locally by inheriting from them and building a new image with all the user specific things, and run them in a user specific way (proxy, extensions, CCACHE settings, etc). It'd be nice to keep the devcontainer.json as a generic template and have initializeCommand do whatever it wants and to use these effects in the devcontainer.json. This way we could use scripts to extract image versions, parse various untracked user files for CCACHE configs, etc, so that each user can fine tune the environment without having a dirty working tree.

Steps to Reproduce:

  "name": "${env:DEV_IMAGE_NAME}",
  "build": {
    "dockerfile": "Dockerfile",
    "args": {
      "IMAGE_URL": "${localEnv:DEV_IMAGE_URL}",
      "DOCKER_REGISTRY_URL": "${localEnv:DOCKER_REGISTRY_URL",
      "USERNAME": "${localEnv:USER}",
      "USER_UID": "${localEnv:USER_UID}",
      "USER_GID": "${localEnv:USER_GID}"
    }
  },
  "initializeCommand": "${localWorkspaceFolder}/.devcontainer/initialize-command.sh",

bence42 avatar Jul 22 '22 09:07 bence42

ping

bence42 avatar Aug 10 '22 06:08 bence42

pingity ping pong

bence42 avatar Aug 17 '22 13:08 bence42

is it on?

bence42 avatar Sep 29 '22 13:09 bence42