In my docker-compose.yml, I set environment NODE_ENV
node2:
image: ...
environment:
- "NODE_ENV=production"
My Dockerfile,
FROM node:latest
... //all the ususal stuff
CMD ["npm", "start"]
My npm,
"scripts": {
"start": "NODE_ENV=development node --inspect ./bin/www"
},
But when I run docker-compose up, I found the nodejs code still runs in development, not in production. Why is that?
My second question is what is the proper way to achieve what I want to do here, when running my nodejs without docker, i.e. using npm start
, I want it to run in development mode, but running docker in production mode?
---- update -----
For my first question now I understand it is my npm start
overwrote NODE_ENV=production in docker-composer.yml not the other way around.
But for my second question, I am still looking for an easy solution.
Thanks for the answers I got so far.
development
as you override yourNODE_ENV
in your start script? – Henrik Andersson