I've deployed a lot of services and I want to share a list of actions that I usually perform. No clouds, just oldschool vps.

Deploying a Node.js application require this steps:

  1. Create an instance of vps.
  2. Update & upgrade the system.
  3. Install node version manager (nvm) for simplify installation of any node version. Today we can just use the standard version, but I still like to be able to switch node version in a seconds.
  4. Install node process manager. I prefer pm2. There are other options, but pm2 just does its job and is suitable for microservices architecture. The main purpose of pm2 in my case is to keep node application running and autostart my application even if something goes wrong.
  5. Add a DNS record that would point some domain to the servers IP.
  6. Caddy server. Fast and simple configurable server. It automatically gets SSL certificate from Let's Encrypt. It proxies our node service from any port and serve it as https. There is a way to set up a websocket configuration.
  7. Clone your git repository. Go into that folder and resolve deps.
  8. Run pm2 startup to configure your server in a way that it would automatically launch pm2 if reboot happens at some point.
  9. Run pm2 start index.js from the project folder.
  10. Configure caddy through a Caddy file and start it.