Open hellodword opened 9 months ago
Yeah, I need to access some credentials in install.sh
and for now I had to try to fall back to mounting some kind of file instead of using env vars.
devcontainer-feature.json
"containerEnv": {
"ARTIFACTORY_USERNAME": "${localEnv:ARTIFACTORY_USERNAME}",
"ARTIFACTORY_PASSWORD": "${localEnv:ARTIFACTORY_PASSWORD}"
}
remoteContainers-….log
[2024-02-20T20:47:34.686Z] ERROR: failed to solve: rpc error:
code = Unknown
desc = failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0:
rpc error: code = Unknown
desc = failed to process "\"${localEnv:ARTIFACTORY_USERNAME}\"": unsupported modifier (A) in substitution
/tmp/devcontainercli-USERNAME/container-features/0.56.0-1708462050881/Dockerfile.extended
ENV ARTIFACTORY_USERNAME="${localEnv:ARTIFACTORY_USERNAME}"
ENV ARTIFACTORY_PASSWORD="${localEnv:ARTIFACTORY_PASSWORD}"
RUN --mount=type=bind,from=dev_containers_feature_content_source,source=MY_FEATURE_NAME_0,target=/tmp/build-features-src/MY_FEATURE_NAME_0 \
cp -ar /tmp/build-features-src/MY_FEATURE_NAME_0 /tmp/dev-container-features \
&& chmod -R 0755 /tmp/dev-container-features/MY_FEATURE_NAME_0 \
&& cd /tmp/dev-container-features/MY_FEATURE_NAME_0 \
&& chmod +x ./devcontainer-features-install.sh \
&& ./devcontainer-features-install.sh \
&& rm -rf /tmp/dev-container-features/MY_FEATURE_NAME_0
devcontainer-feature.json:.mounts
"mounts": [
{
"source": "$HOME/.netrc",
"target": "/root/.netrc",
"type": "bind"
}
]
Because it's not mounted when install.sh
is executed:
> [dev_containers_target_stage 5/6] \
RUN --mount=type=bind,from=dev_containers_feature_content_source,source=MY_FEATURE_NAME_0,target=/tmp/build-features-src/MY_FEATURE_NAME_0 \
cp -ar /tmp/build-features-src/MY_FEATURE_NAME_0 /tmp/dev-container-features \
&& chmod -R 0755 /tmp/dev-container-features/MY_FEATURE_NAME_0 \
&& cd /tmp/dev-container-features/MY_FEATURE_NAME_0 \
&& chmod +x ./devcontainer-features-install.sh \
&& ./devcontainer-features-install.sh \
&& rm -rf /tmp/dev-container-features/MY_FEATURE_NAME_0:
Hello!
Thanks for providing a detailed description of the issue, very helpful.
Is it possible that the devcontainer-feature.json keep the same logic of containerEnv & remoteEnv with devcontainer.json in the future? Or at least support the ${localEnv:*}?
This request makes sense, moving this issue to the spec repo.
related issues:
docs:
First test a
devcontainer.json
:build and check the env:
Then the
devcontainer-feature.json
,remoteEnv
is not allowed, and all the${*:*}
pattern will throw an error:build and check the env:
I have some questions:
Is it possible that the
devcontainer-feature.json
keep the same logic of containerEnv & remoteEnv withdevcontainer.json
in the future? Or at least support the${localEnv:*}
?Check the outputs, have you considered about evaluating these as empty string? Similar with the behavior of shell.