patternjavascriptMinor
node js deployment on production server
Viewed 0 times
servernodedeploymentproduction
Problem
I wanted to know standard process to deploy nodejs app on production. As of now I am following the process as below
Pull the source code
Install npm dependencies
Build the code
run the application
But I am thinking of pulling source code to prod is the totally wrong way. Please, someone, guide me the exact way to deploy node app on the production server. Also, any other way to run the app continuously as service. I am aware with pm2 module to run a process in the backend. If there is any other way to manage it properly.
Pull the source code
git pull git_urlInstall npm dependencies
npm installBuild the code
npm run buildrun the application
nohup node server/index.js &But I am thinking of pulling source code to prod is the totally wrong way. Please, someone, guide me the exact way to deploy node app on the production server. Also, any other way to run the app continuously as service. I am aware with pm2 module to run a process in the backend. If there is any other way to manage it properly.
Solution
You could issue an
Note: if you are planning to use
npm pack which will create a tgz and then you could push it to an artifact manager like Nexus3. By doing this one uses the same approach as creating artifacts in Java like JARs and WARs. If you ensure that the artifacts cannot be overwritten, you specify a version and restrict publication to an artifact manager by the CI like jenkins then the artifacts are immutable and you are in control. E.g. if there is a bug in version X you could revert it to the previous version that was working well.Note: if you are planning to use
npm pack I would suggest to use an abbreviation like @angular does to ensure that there is a clear destinction between artifacts that were created by your company and libraries from npmjs.org. This could be done by adding an abbrevation of your company like @z to the package name. A name could look like: @z/some-package.Context
StackExchange DevOps Q#6337, answer score: 1
Revisions (0)
No revisions yet.