0

I'm rewriting a project from scratch using best practices and better config variables. The idea is to have at least 3 environments:

  • development = hosted locally (on machine)
  • acceptance = hosted on personal NAS
  • production = hosted on rented server

After some research I came across the following answer (on how to set NODE_ENV): 9198310

Doesn't this mean I have to change the environment manually before each code push? Is there a way to do this automatically by checking IP or DNS?

FYI, I'm using docker to host the website on acceptance & production. Not locally.

Community
  • 1
  • 1
Goowik
  • 782
  • 11
  • 36

1 Answers1

0

You can export NODE_ENV for each environment (can be added on profile.d on OS level) and then just start your nodejs app which will read that env. variable.

"scripts": {
    "start": "node ./app"
  }

When run docker, you can set env. variable using:

 -e NODE_ENV='staging

Also you can take a look at pm2 manager.

Tareq
  • 5,283
  • 2
  • 15
  • 18