Some monitors needs an endpoint in our apps to show a dashboard with stats or metrics.
In java, the most secure and complete framework called spring offer a feature called actuator that expose a lot of http endpoints. One of them is able to show the environment variables. You can disable this feature or set a security credentials for production
Also in python, django framework, when the debug variable is true, on any error, an html page is displayed with the stacktrace of the error plus environment variables.
So, is not a crazy idea to have this feature in nodejs. You just need to add a simple express route and return the process.env
app.get("/meta/vars", function(req, res){
if ( some_security_logic || process.env.NODE_ENV == "PROD") {
return req.send({});
}
req.send(process.env);
});
Configuration Manager
Variables to be used at runtime but exposed at build time is not a good practice because breaks one of the docker features: One build for any environments: dev, stagging, production, etc
To have variables in files like: .env .properties .ini or any extension , requires a manually write task performed by a human. This breaks the devops automation. Also needs some storage like git repository which is another bad practice.
At this point I advice you to use some application wich is responsible to manage all the variables of all the applications in your company. This app must be secure and offer features like hide password, encrypt sensitive values and a secure way to consume these variables by a specific application. Here some options:
With a tool like previous options, you don't need to add manually variables at build time. Your app just need to obtain its variables consuming a secure http endpoint published by the Configuration Manager Platform.