Closed ivn-cote closed 7 years ago
@ivn-cote Actually, the PORT is set in packages.json
@wellyshen let me tell you how usually the deployment happens. Automation script grabs the project from a repository (or docker image from a docker repository) and put it in the cloud or on real servers. And usually the port for the service is unstable. It could be very random in some setups (Marathon cluster). As you can imagine, there is no opportunity to paste it in package.json. Service itself should be able to be started with a special configuration setup, including port.
@ivn-cote
In packages.json
remove the PORT
command from start:prod
(as the below) and use the command PORT=<your port> yarn start:prod
.
"start:prod": {
"command": "node ./index.js",
"env": {
"NODE_PATH": "./src",
"NODE_ENV": "production",
"PORT": 8080 <== Remove it
}
},
They're the same result, the different is you pre-define your port through packages.json
or dynamic declare it by terminal.
So there is a difficulty I struggle with. I'd like to run the project in production mode with a custom port. Right now as I understand I have to change this in the configuration file. But the standard approach is setting environment variables only, like this:
PORT=80 yarn start:prod
. So maybe I'm missing something. Could you please describe in details how the result application should be deployed? Thanks!