What is the easiest way to deploy Phoenix on a VPS?
It depends what You mean by easy…
If You mean with the less tools possible, then building a release, push it on the server, configure systemd to start the application might be the easiest.
Please give details or at least point me to some articles on how.
This is only the easiest way when one uses the same system as the VPS and always keeps them at the same upgrade/patch level.
The absolutely easiest way is to install elixir and erlang on the server and compile there and use
mix phx.server in a
That’s why I said it depends…
Compiling on the server needs to have Erlang and Elixir installed. But a release does not.
I made a post long time ago… it used distillery
But this might be more appropriate now
So how do I actually start mix phx.server so it’s always on like Nginx server?
Depends on a lot of things… But my personal goto solution is, to write a systemd service unit that’s manages the lifecycle of the program.
I deploy Elixir and Phoenix apps on VPS’ a lot for clients and it’s a lot of repetitive work that’s easy to mess up each time.
I’m actually working on a service to automate it all, called tap.works. It’ll handle initial server configuration, DB and Nginx with let’s encrypt if you need them, and handle deploying releases. So if anyone gets tired of doing that work it’ll be a reasonably priced way to have it done for you.
I wrote a sort of mini-guide of how I set up Phoenix with Distillery, Nginx and Let’s Encrypt in the past. It starts Phoenix in the background at server startup using Systemd. You can find it here: Using LetsEncrypt with Phoenix (behind Nginx). How to make this more optimal?
Use Dokku (Digitial Ocean has an image ready to deploy). Follow the fairly easy instructions to create an app and database and you are done. Only good for small projects but it is easy.
Not sure if easiest, but there has been zero maintenance required for us with this setup: https://dreamconception.com/tech/phoenix-automated-build-and-deploy-made-simple/
Apart from provisioning your server, everything is there. Here’s the repo: https://github.com/danschultzer/ansible-phoenix-build
Also, it uses 1.9 releases rather than distillery
I haven’t used this tutorial but it might be useful to you If you are looking for a minimal setup (no docker etc) https://medium.com/3-elm-erlang-elixir/how-to-deploying-phoenix-application-on-ubuntu-293645f38145
it seems that tap.works hasn’t launch their service yet, they are still saying that they are under development, and they will launch in summer 2019