Hi, great article! Thanks for sharing your knowledge with us.
I have a doubt about best practices for handling environment variables.
Reading your Dockerfile, i felt a little strange seeing NODE_ENV=development in builder and start:prod later on. I would expect one environment to be the 'default' and the other one would have to override what is needed. But I didn't see it in here, is the default one 'development' or 'production'?
I understand npm install works based on NODE_ENV variable, so whether development or production, it will work as expected.
Is there a similar solution for npm start? To run the correct command based on NODE_ENV variable?
Hi, great article! Thanks for sharing your knowledge with us.
I have a doubt about best practices for handling environment variables.
Reading your Dockerfile, i felt a little strange seeing
NODE_ENV=development
in builder andstart:prod
later on. I would expect one environment to be the 'default' and the other one would have to override what is needed. But I didn't see it in here, is the default one 'development' or 'production'?I understand
npm install
works based on NODE_ENV variable, so whether development or production, it will work as expected.Is there a similar solution for
npm start
? To run the correct command based on NODE_ENV variable?you can have your npm scripts like :
start:development
andstart:production
In the Dockerfile, you can use
CMD [ "npm", “run”, "start:${NODE_ENV}" ]
.Hi, I have the same doub, if you have found a solution, please shared it, I would appreciate.