Injecting Variables Through (b)ash

Using a Multi-stage Dockerfile

Another option is to use a multi-stage Docker file, where the first stage is still using nodeJS, like this. This way node can still parse the environment variables as you would during local development, and the final deployed image is. However, in large organizations deploying such a multistage container in a production environment may irk some SecOps people. See: earthly.dev/blog/docker-multistage/ for some explanation about security concerns.