What's the best way to deploy a Phoenix app in production?

I advise You to read about release documentation if You want to deploy on VPS :slight_smile:

https://hexdocs.pm/phoenix/releases.html

2 Likes

thanks @kokolegorille. I’ll have a look

I’m having issues deploying a simple gatsby site on Render. I’m trying it to see how it feels without having to pay 7 dollars but it’s already failing.

I successfully deployed a Create React App. But routing is missing. SPAs should be redirected to index.html. Does it have that feature?

update: it does. I would have to try it without paying first. Otherwise VPSes/Dedicated servers are my first choice for now.

You can set up a rewrite to /index.html using this guide: https://render.com/docs/redirects-rewrites

Happy to look at your Gatsby build if you want to send us details in render.com/chat.

thanks! I already looked at the docs for the rewrite. Render seems to be a good alternatives to free services such as Netlify. Tho it doesn’t offer anything more than what Netlify does. Anyway I’m looking into for Phoenix. Not static sites.

The gatsby build stated something about make. But like I stated I’m here for Phoenix. And having some free trial or free tier would be great to try it tout.

There are a good range of opinions posted in this thread too :smiley:

3 Likes

We’re thinking of introducing a free trial that lasts a week or two. Re: your Gatsby build, I think you’ll need to pin your Node version to >=10 <11 in package.json as outlined here: https://render.com/docs/deploy-node-express-app#a-note-on-node-versions

1 Like

thanks! I’ll have a look

thanks! I had a look at it.

alright then. Thanks

Hi @anuragg, where are your servers located? I saw that you use Google Cloud Platform, is that all on the US West Coast? Is the CDN network Google’s?
Thanks.

:slightly_smiling_face:

3 Likes

You can try some of these options:

The way you presented these options are a little confusing, because some of them are not ways to deploy a Phoenix app - maybe this is a language barrier? (natural language, not programming language)

gigalixir is what you want, if you do not want to deal with infrastructure. Run one command to deploy, and be done with it.

distillery can be used with, for example, edeliver but it does not deploy your Phoenix app. from the README:

it takes your Mix project and produces an Erlang/OTP release, a distilled form of your raw application’s components; a single package which can be deployed anywhere

mix release same as distillery but different :slight_smile:

docker container is, in my own understanding (I might be very wrong here), a way of running apps in separated environments, very close to (but apparently different to) virtual machines. From their own website:

Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space.

My personal preference to deploying a Phoenix app in production is a Ubuntu droplet on digital ocean, install postgres, nginx, and elixir, and then use that server as the build server with edeliver. Once it’s set up, it’s as easy as running mix edeliver update production, and maybe mix edeliver migrate production.

2 Likes

We have a company guide to deploying Phoenix on Ubuntu Server - it assumes some knowledge of Ubuntu Servers, Elixir, and postgresql - but it should be good enough to guide an apprentice to deploy their first Phoenix app.

If there is anything very wrong, or a problem when following this guide, let me know.

2 Likes

hey @Ninigi that’s actually what I did. I followed two tutorials and combined them when one fell short to deploy my first Phoenix app to production on an Ubuntu server on Vultr (Prefer them instead of Digital Ocean).

1 Like

If you are looking for an end to end deploy solution, Gigalixir (similar to Heroku) and Edeliver (Similar to Capistrano) are the best options. However, distillery and mix release can be considered ways to deploy a phoenix/elixir application to production. You can read about it on their documentation.

The point is distillery and mix release requires additional works to make your application alive, that is the main difference from Giga/Edeliver

For the last, I’ve suggested Docker as a solution because nowadays is very common to use docker (k8 or docker swarm) in production infrastructure. So, I’ve only suggested a ready-to-use elixir docker image to run in your infra

In my opinion is very important an elixir programmer know all the possibilities to find out what fits more according to their resources (time, $$)

2 Likes

Very insightful @pierreabreup. Thanks!

1 Like

Your original post was a little weird, I did not assume you don’t know about all that.

Nothing else to say, you are saying what I assumed you said.

On a personal note: I don’t like docker, I have used it, and am working with legacy apps using docker. The legacy apps are the worst (doen’t have anything to do with Elixir) It’s all a blackbox, and the last time I tried to update, it broke and I had restore the server from a snapshot.
I don’t know how yaml configuration makes things easier than learning basic Linux bash commands, it seems to be so much harder to debug (on the infrastructure level) and… I guess I am the old guy yelling at clouds here, I think it’s a fad.
Don’t mind me, I also think React is a fad, I think it breaks how the web was supposed to work, and I think virtual DOMs are a fad - because browsers and computers are getting faster still.
I use Firefox, not Chrome - and for at least 6 months now, I actually think it is the better browser.

Everyone, you go use docker. It’s probably great! I haven’t seen what it offers over a vanilla server yet, but maybe I will have to come around. Seriously. I know it sounds condescending, I just want to state my opinion.