node8-express-template icon indicating copy to clipboard operation
node8-express-template copied to clipboard

Setting NODE_ENV to production by default

Open Templum opened this issue 6 years ago • 4 comments

Currently, we already configure the log level of NPM and further only install production (runtime) dependency.
I suggest the default setting of NODE_ENV to production as this will increase the overall performance of the express server, without any additional effort.

Templum avatar Oct 22 '18 20:10 Templum

I'm generally for this. Would it benefit the normal node template too? What are the side effects for people relying on this for debugging and how does it impact them?

alexellis avatar Oct 22 '18 20:10 alexellis

Regarding the benefit to the normal node template: The thing is, at least for express it will make an impact. Usually, the application needs to make use of the parameter, for example, to reduce unnecessary logging or unnecessary logic. Overall it might, but it is not guaranteed. However, it should not negatively impact it.

Regarding the side effects: I'm not aware of side effects, it might reduce the overall logging verbosity, however, if it is clearly stated you can override it on demand in the stack.yml. And I believe it is more likely that you will end up forgetting to set it to production. So if someone is actively developing, he can make use of the overriding.

Templum avatar Oct 22 '18 20:10 Templum

I like the idea of it as a default, so long as it could be overridden. For example, we could set NODE_ENV=production in the Dockerfile, but override it with -e on the CLI, stack.yml, docker-compose.yml, etc.

telackey avatar Oct 22 '18 20:10 telackey

I like this proposal, also for the regular template. As I debug, it wont have any side effect, besides it can be overriden.

padiazg avatar Oct 22 '18 22:10 padiazg