On Heroku I'm trying to release a pushed image as described here: https://stackoverflow.com/a/50788844/2771889
docker build --file Dockerfile.prod --tag registry.heroku.com/my-app/web .
heroku container:login
docker push registry.heroku.com/my-app/web
heroku container:release web
My heroku.yml looks like this (used when I deploy from GitHub, and works fine):
build:
docker:
web: Dockerfile.prod
release:
image: web
command:
- yarn typeorm migration:run && yarn console seed
run:
web: yarn start:prod
It seems that the run command is not taken into account. When running container:release the logs show:
Starting process with command node
Whereas during a release from GitHub I'd see the correct command:
Starting process with command /bin/sh -c yarn start:prod
The release command however is recognized and executed correctly.
How can I make sure container:release runs the container with the correct command?
I had to add a CMD to my Dockerfile:
# ...
CMD yarn start:prod
This doesn't break GitHub deployments with heroku.yml.
Related
This is my error image getting on heroku logs --tail
above is a given image of my errors. When I am trying to deploy my nodejs app Getting error on git push Heroku master .
.
.
.
Remote failed
working properly on local server. I am beginner please help my git id is cosmos-dx and there is a git repo of name Webdictionary
After reading through the nodemon docs, and taking the fact that you stated you are new, I think I know what is happening.
In the nodemon docs it gives you two ways to install, one is globally npm install -g nodemon and the other is to install it in the dev dependencies npm install --save-dev nodemon. Either of these options would make nodemon not be present if the build to heroku uses npm install --only=production. I assume they do that.
In your package.json file, change the npm start script to this:
"start": "node ser1.js"
As nodemon is not present in the heroku built application, your current start script will fail. If you want to continue using nodemon for local development you can add a new script:
"dev": "nodemon ser1.js"
From there to run your application, with nodemon, on your local machine you would run npm run dev
I working on laravel project and I need run this command in the terminal in Cpanel npm run dev
Do have installed it? If so, try to find /node_modules/npm/bin/npm-cli.js and run it with full path starting root.
Like:/usr/lib/node_modules/npm/bin/npm-cli.js -v
I have reactjs project that need to be run on the linux server. Whenever I run the app on server using "sudo npm run lin_stage_server" it seems to be working fine on 80 port.
when I tried to run app through pm2 with command "sudo pm2 start npm -- lin_stage_server" its not working for me.
In addition to the above command i also tried
"sudo pm2 start npm -- BRANCH_ENV=stage NODE_ENV=production PORT=80 node appserverstart.js
"
Please help !
----- Error details ------
Error details
----- Package.json -----
Package.json
----- appserverstart.js -----
appserverstart.js
-------Additional info-------
server: CentOS Linux version 7 core,
npm version: 6.4.1,
pm2 version: 3.5.1,
node version: 8.11.1,
You are not passing run to npm:
pm2 start npm -- run lin_stage_server
pm2 start npm -- lin_stage_server is effectively npm lin_stage_server.
pm2 start npm -- run lin_stage_server is effectively npm run lin_stage_server
I'm going to run react-boilerplate application forever in the server.
I found forever and I'm not sure how I pass parameters to forever. The command to run server is like following:
PORT=80 npm run start:production
Seems like forever start PORT=80 npm run start:production doesn't help me.
One thing is that PORT=80 part is setting the env variable, this kind of command should be in front of other commands. The other thing is that to run npm scripts with forever, you need to use different syntax, so PORT=80 forever start -c "npm run start:production" /path/to/app/dir/.
If you're running forever form the project folder, the path should be ./
Or you can run a react application with pm2 or with nohup
1) install pm2 globally
npm install pm2 -g
2) navigate to the project folder and execute, space is required after --
pm2 start npm -- start
3) to see running instances
pm2 ps
4) to see the other options
pm2 --help
To run with nohup
1) navigate to the project folder
nohup bash -c 'npm start' &
pm2 is superb production process manager for Node. In addition to starting and daemonizing any application, it has a built in load balancer.
Install pm2:
npm install pm2 -g
To add start and add deamon to your app, navigate to the app folder and:
pm2 start app.js
To make pm2 autoboot on server restart:
$ pm2 startup
Then copy and paste the code generated.
For this you will need:
Install forever usingnpm install -g forever
Run the forever command PORT=<YOUR PORT> forever start -c "<command>" ./
Your command can be for example npm start and npm run dev.
Use ./ only if you are in the project folder.
Port means your port number, usually 80 or 443.
Im trying to deploy an nodejs app to eb, all my code is using the new js features.
On my package.json I have start command:
scripts : {
start: "babel-node bin/start.js"
}
this works fine on my localhost, when I deploy the app to EB, i get the error on the logs saying:
sh: babel-node: command not found
Can i run the babel-node command on a cloud server, or shall i compile my code before deployment.
Include babel-cli as a dependency in your package.json
You can do this by doing npm i babel-cli
However
That solves your problem but babel-node is not recommended for production use as stated in the usage docs