Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace /etc/profile.d for Environment Variable Persistence in Dockerfiles #1789

Open
c-ewing opened this issue Dec 3, 2024 · 0 comments · May be fixed by #1790
Open

Replace /etc/profile.d for Environment Variable Persistence in Dockerfiles #1789

c-ewing opened this issue Dec 3, 2024 · 0 comments · May be fixed by #1790

Comments

@c-ewing
Copy link
Contributor

c-ewing commented Dec 3, 2024

In the Docker files there are several cases of writing to /etc/profile.d/alicevision.sh as a way of persisting environment variables. Unless I am mistaken these variable's are only used by the build scripts in the Docker images/containers. There is an issue with this however as RUN (in the Dockerfile) and docker run from the command line do not execute login scripts under profile.d. There are several sources for this but this page explains it nicely.

Basically all of the shells launched by Docker are non-login shells, meaning they do not execute login scripts in /etc/profile(.d) unless specifically invoked as a login shell.

I propose rewriting lines such as:

COPY dl/vlfeat_K80L3.SIFT.tree ${AV_INSTALL}/share/aliceVision/
RUN echo "export ALICEVISION_VOCTREE=${AV_INSTALL}/share/aliceVision/vlfeat_K80L3.SIFT.tree" > /etc/profile.d/alicevision.sh

COPY dl/vlfeat_K80L3.SIFT.tree ${AV_INSTALL}/share/aliceVision/
ENV ALICEVISION_VOCTREE=${AV_INSTALL}/share/aliceVision/vlfeat_K80L3.SIFT.tree

This will clarify what the command is doing in the context of the Docker container while also properly persisting environment variable across RUN commands and through the layers in the multistage build.

If the alicevision.sh script is used elsewhere I could not find reference to it but please correct me if I'm wrong.

See #1790

@c-ewing c-ewing linked a pull request Dec 3, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant