spec icon indicating copy to clipboard operation
spec copied to clipboard

Proposal: Allow using env-vars in devcontainer-feature.json

Open max06 opened this issue 2 years ago β€’ 8 comments

My current use case involves defining additional container mounts in the future users home directory in the container. It seems to be impossible at the moment, since the remoteUser is configurable.

${devcontainerId} seems to be the only variable that can be used in the devcontainer-feature.json file. There are 2 env variables mentioned in the feature spec (_REMOTE_USER_HOME and _CONTAINER_USER_HOME) but they are only accessible in the install.sh-script.

I'd like to have access to more variables, either the ones passed to the install-script, or the ones used in the parents devcontainer.json.

max06 avatar Apr 01 '23 22:04 max06

Hi πŸ‘‹

I agree, it would be helpful if we could make environment variables passed to the devcontainer.json and added as Feature options available to devcontainer-feature.json.

Our current set of dev container Features would benefit from this as well, we have https://github.com/devcontainers/cli/issues/391 opened which tries to tackle another such scenario.

samruddhikhandale avatar Apr 03 '23 20:04 samruddhikhandale

Hello there, once again... can I do something to get this going? I'd love to finish some devcontainer features but they depend on these variables...

max06 avatar May 15 '23 11:05 max06

Hi πŸ‘‹

We currently have this issue in our backlog, @bamurtaugh @joshspicer looking for your thoughts on this one.

samruddhikhandale avatar May 15 '23 16:05 samruddhikhandale

I agree this one sounds useful, thanks for opening @max06!

Since this is an open spec, we really value feedback and contributions too. @samruddhikhandale @chrmarti would you find it reasonable to suggest anyone from the community could also contribute this request via PR to https://github.com/devcontainers/cli? If so, then @max06 you'd be able to kick this off directly!

bamurtaugh avatar May 15 '23 20:05 bamurtaugh

Oh boy!

Alright, I'll give it a try πŸ˜…

max06 avatar May 15 '23 20:05 max06

Looks like I overestimated my abilities here πŸ™ˆ (Any help/hint would be greatly appreciated!)

max06 avatar May 17 '23 15:05 max06

Adding another use case here, would be great to be able to use ${localEnv:HOME}${localEnv:USERPROFILE} for the mounts in features. I'm working on a feature to allow adding Python packages using a requirements.txt and it would be great to be able to give users the options to use a requirements.txt that's store on their host rather than in the container. Don't see a way to accomplish this otherwise.

natescherer avatar Jun 13 '23 18:06 natescherer

I gave it another try - and was more successful than last timeπŸ₯³

max06 avatar Jul 25 '23 22:07 max06