AliceVision
AliceVision copied to clipboard
Replace /etc/profile.d for Environment Variable Persistence in Dockerfiles
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: https://github.com/alicevision/AliceVision/blob/7d73bc0f92c5345ebd59095fb7eabd31e909e934/docker/Dockerfile_ubuntu_deps#L64-L65
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