Nitrogen: How do we deploy it (VPS)?

Hi! just a quick question: can you give me some advice(s) or articles about deploying a Nitrogen web app in a vm (VPS)?. I have a simple crud app, and asking what’s your take regarding deployments. Many thanks!

Hi @jaeyson,

If you’re using the most recent commits (in the past month or so) from the master branch, then your Nitrogen app should be using rebar3 by default.

Assuming that’s the case, you have two main options available to you:

  1. If you’ve got your entire project in git (or other vcs), then on your destination machine, the simplest approach would be to clone that project on your VPS then run make release. (this will build a usable release on the remote machine). From there, you can run make run_release to start the release.

  2. If you’d rather not clone your entire project on the destination machine, then on your development machine, run make release. This will create the release in _build/default/rel/. From there, you can tar up that container directory up and drop it on your VPS. Once that’s extracted on your VPS, you can start the release from the your_app_name executable in the bin directory. bin/your_app_name daemon will start it in daemon mode, and bin/your_app_name console will start it with an interactive erlang shell (all the relevant commands are on

Personally, I like the first method, as it’s easy to upgrade the running release with make upgrade_running

If, however, you’re still on Nitrogen 2, then I would just tar up the whole project directory, extract it on the target VPS, and run it just as would would in development.

All that said, in both cases, the default port is going to be 8000. So I’d recommend using nginx as a reverse proxy in front of it. If you’re unfamiliar with nginx, check the bottom of the page for the configuration docs for Nitrogen, which has some nginx configuration options that can help you get that configured.


@gumm thanks a lot for the info! one last question: will option #1 be better for CI (e.g. github actions) where after successful tests, then run a deploy script?

Yeah, that’s the way I’d go.

1 Like

@gumm Thanks alot! :pray:

1 Like