Simple node.js app deployment on DigitalOcean from

2020-03-06 08:27发布

问题:

I have a node.js application on my Github. Right now I am using Heroku for hosting it but I want to give DigitialOcean a try (the $5/month is more affordable).

I am used to using Heroku, where I just go create an app > connect it to my github account > deploy from the master branch > boom app deployed.

When I signed up for DO and started exploring it seemed way too much and too many steps to get my app deployed. I researched around to find a simpler way (similar to one I follow in Heroku) but all the blogs and YouTube videos go through the same tedious process.

I know I am being lazy but I just need a few clicks app deployment. Does anyone know a better (smarter) way I can deploy my app on DO from Github?

回答1:

It will not be as easy with Heroku. It is always tempting to use cheaper services like Digital Ocean or Vultr and pay only fraction of the price (especially using coupon links that can make it free for months - Digital Ocean, Vultr) but having your own VPS means that you need to manage it yourself. Simplifying that process is what you pay for when you're using Heroku. But it doesn't have to be that bad.

Here is a good tutorial on how to do it:

  • https://www.distelli.com/docs/tutorials/build-and-deploy-nodejs-to-digitalocean/

And see this list of tutorials - search for those with "deploy" in the title:

  • https://www.digitalocean.com/community/tags/node-js?type=tutorials

Basically you have few options that I would consider here:

  1. A semi-manual deploy with git - You can install a git server on your VPS and push to it whenever you want to deploy a new version

  2. Automatic deploy with git - You can add a deployment process to you CI scripts that will do what you do manually in (1) but after all tests pass

  3. You can trigger a pull from git on the server with ssh or a custom API

  4. You can do (3) in your CI scripts

  5. You can add a custom webhook in GitHub to notify your server about new version and your server may then pull the code and restart

  6. You can add a custom webhook in CI and do the same as in (5)