docker-nginx-unprivileged icon indicating copy to clipboard operation
docker-nginx-unprivileged copied to clipboard

Source instead of execute entrypoint scripts

Open MShekow opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe

We are using the 20-envsubst-on-templates.sh script to replace ${SOME_ENV_VARS} in a specific file. For a specific use case, we want to enforce a few environment variables+values, such that our endusers of the image don't need to specify them, and even if they do, their values are not used, but our enforced values are used instead. Currently there is no way of doing that, without hacking the docker-entrypoint.sh file.

Describe the solution you'd like

Our envisioned solution approach is to put a simple shell script into the image, e.g. at /docker-entrypoint.d/15-fix-env-vars.sh that contains a bunch of export FOO=bar lines. For this to work, https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/entrypoint/docker-entrypoint.sh#L22 would have to be changed to source the script, instead of just executing the script.

Describe alternatives you've considered

We are not aware of any alternatives that allow us to enforce environment variables. Declaring ENVs in the Dockerfile only sets a default value, but does allow the enduser of the image to override the values using docker run -e ....

MShekow avatar Apr 05 '22 14:04 MShekow

I would open this issue in the upstream https://github.com/nginxinc/docker-nginx repo. At first glance this seems to be a reasonable request so it might get implemented there. If it does get implemented, I will update this repo too.

alessfg avatar Apr 05 '22 19:04 alessfg

A tentative solution has been implemented as of c03e750

alessfg avatar Sep 19 '22 12:09 alessfg