I was having issues understanding how to deploy Phoenix applications, and decided to write an article on how I was eventually able to get it working with Distillery and Edeliver.
Thank you very much for writing this - it’s almost exactly what I’m planning to do once I get my app to a state where it’s worth deploying. When that happens (which may still be a few weeks away), I’ll give this a go and let you know how I get on.
looks great from a quick scroll through… good job
feedback:
I would strongly suggest using a package manager like asdf (or other) to install elixir and even node (to be able to maintain dev/staging/prod parity by installing very specific versions - and also to have elixir compiled against the used otp version)
Making nginx optional - eg showing how to run phoenix directly on port 80, would be a nice addition. + ssl maybe?
Thanks for the info in the article @tmartin8080! Its the best comprehensive guide that is up to date I’ve been able to find for deploying apps w/o docker to your VPS of choice. Systemd and SSL are important final steps but this gets you 95% of the way there.
The dependencies installation didn’t work unless you add the bionic universe repo iirc. I tinker around with many solution but I believe the one that work was adding the universe repo. Solution.
For $5 droplet it only works if you create a swapspace (I set it via 4GB) and wait a bit for asdf to install and build erlang felt like 30 min. Source for problem.The solution.
For step Step 7:
I think there’s a typo it should be sudo apt-get update
I think you should cd ~ or make sure in home dir after su postgres otherwise it complains about making a directory in root
typo pgsql should be psql
Maybe add \q to quit psql but I’m being picky now.
I’m only on step 9… I’ll update this post later on if you like to hear more. Thank you for making this post.
A out of there suggestion would be using terraform or ansible for these configurations.
But I haven’t used or done dev ops in forever. Terraform is something I’ve been meaning to try out when I have time, I think it does what ansible does…
You can use them both, they complement each other.
Terraform config files declaratively describe the servers/VMs to be created and is meant to be provider agnostic so you can create a mix of cloud servers at AWS, Azure, Digital Ocean, etc etc and local (VMWare), etc. When run it compares the current state of your infrastructure with how you declared you want it to change and it provisions/changes any new resources for you. It’s like CloudFormation but instead of just working with AWS it works with dozens of other providers. IMO it’s very good stuff.
After the infrastructure is created then Ansible (or if you prefer Chef, Puppet, Saltstack, etc) installs, configures, and manages software (such as Nginx, PostgreSQL, Distillery releases, etc) on the newly created servers.
@mythicalprogrammer Thanks for the details! I’m glad you took the time to outline some issues you encountered.
I’ll update the post with some of these finer details, and let me know if you have any more issues.
About terraform et al, This was just meant to be a gentle intro to deployments and I think adding in complex tooling would make it less approachable to some people.
I’ll update the post with some of these finer details, and let me know if you have any more issues.
I just finished deploying with your tutorial (minus setting up nginx section).
I’ve encountered 3 4 issues.
Another problem was I had to disable passphrase on my ssh key otherwise edelivery would throw error. I have no solution for this other than removing passphrase from my existing ssh key.
Another issue was ** (Mix) The task "release" could not be found. The reason turns out to be I didn’t commit to git master branch and I was in a branch. Solution and detail of problem.
After deploying. I couldn’t figure out why I was getting server error. I figure out after a few minute that my db wasn’t built. After tinkering with config I realize I had to do. mix edeliver migrate production I skimed through the Admin commands section thinking that it wasn’t necessary.