I am trying to deploy my first Phoenix app to a Digital Ocean droplet. My local machine is a Mac running Unix and the Digital Ocean droplet is Ubuntu 16.04.
I have been following this guide
I can make it all the way through step 7 where it actually deploys using edeliver and distillery. I build the release on my local machine. I can transfer the release to the production server with:
mix edeliver deploy release to production
It tells me my release was deployed to production so I run:
mix edeliver start production
which it tells me it starts. I have my app configured to port 4000 so when I visit http://example.com:4000 with example being my site domain or ip-address it refuses the connection. So I open my Ubuntu server and see if there is anything running on port 4000 using
lsof -i :4000
and there is nothing running on that port. I don’t even know where to begin to troubleshoot anymore because I’m not running into any errors going through this tutorial. I thought it might be the firewall so i added 4000 to be allowed within ufw.
I wanted to avoid using a service like Heroku or gigalixir, but I am getting ready to throw in the towel for now and just switch. Is there a decent tutorial on how to deploy without having to use Docker or Heroku?
I followed that tutorial and managed to get my site up but it took me a few days to figure it out. I had a hard time because I’m not very familiar with the devops part of stuff like nginx. It also was annoying because it costs money every month even for the smallest droplet and for a hobby or new app that you are just trying to get deployed it’s not worth it in my opinion.
Either way, when it came to troubleshooting I remember there were logs being saved somewhere on the server that you should be able to pull up about your app and it’ll give you some clues. These were erlang logs I think. I wish I could be more specific but It’s been a while.
The fastest route to deployment has been heroku in my experience. But after trying to internalize the “phoenix is not your app” mantra and get a better handle on what it means to leverage OTP, it’s hard to justify using Heroku since it has to reset its dynos daily, effectively killing any long-running processes.
My most recent project I decided to try gigalixir which I have to say so far, I am thoroughly impressed. Amazing documentation. Insane customer service! You get hot code upgrades and all that stuff baked in. And the free tier is sufficient for most hobby apps.
You should build your release on a machine that runs the same operating system in the same version with the same library versions.
Since you said your local machine is a Mac and your remote is a Ubuntu, you should either build on the target (which I’d not recommend) or in a Ubuntu 16.04 VM on your Mac.
I thought that was the case. I think I might take @Most’s advice and try gigalixir.
Try this template: https://github.com/cogini/elixir-deploy-template
It is a step-by-step process for building and deploying a Phoenix app using Ansible.
I have been testing it on a Digital Ocean droplet with CentOS 7, Ubuntu 16.04 and 18.04.
I am preparing it as part of this guide:
Please give me your feedback / questions.