How to Deploy a Node.js App to Production with Git

15th May 2023

You can use GitPushLive to deploy node apps to your own servers. This allows you to choose from a large number of server providers and configurations to best meet your cost / performance requirements. It also has no lock-in and allows you to add additional databases and services as required without additional cost.


Deploying a Node.js App to your GitPushLive Server


1. Pull in our node sample app with the following commands

# clone our demo repository
git clone [email protected]:GitPushLive/node-sample.git
# change into the project folder
cd node-sample
# install dependencies
npm install
# test the app
node index.js


If you open your web browser at http://127.0.0.1:3000 You should see the simple output of “Hello World!”

You can now press ctrl + c to stop the node app from running.

2. Deploy this app to your server ( below presumes your server is called d1.server.com )

# add your git remote 
git remote add live [email protected]:node-sample
# push it live
git push live

If you open your web browser at http://node-sample.d1.server.com you should now see the app running on your live server

Sample Project Explained.

The above code is able to run because

  • Dokku sets up an Nginx reverse proxy to manage your traffic from the above custom domain.

  • The Node.js environment is setup with the Dockerfile here.  

  • Dokku runs the command held in the Procfile here.

  • This project uses the command npm start which is determined by the content of the package.json file here

  • The app knows which port to listen on by using the PORT environmental variable here.

The above app is a very basic express app with a single endpoint. However the principle should be the same for more complex applications. We plan to add more tutorials on how to use databases from with your node apps.


Other Deployment Options


Manual Deployment

Deploying node.js apps can be tricky as you need to setup some kind of server, process manager, reverse proxy etc. To do this without GitPushLive you can follow something like the Digital Ocean Tutorial Here.


Using a Proprietary PAAS Solution

Another way is to sign up to one of the many App platforms to host it for you, you’ll be tied to their eco system so have to pay extra for add-ons like database, backups etc. However this may be a good option if your app fits within their free tier or vendor lock-in ins’t a concern.