SupaSaya

SupaSaya

How to easily deploy Elixir?

I am still doing something similar to this:

https://medium.com/@zek/deploy-early-and-often-deploying-phoenix-with-edeliver-and-distillery-part-one-5e91cac8d4bd
https://medium.com/@zek/deploy-early-and-often-deploying-phoenix-with-edeliver-and-distillery-part-two-f361ef36aa10

I deployed 10+ apps to production and it still always takes me at least 1-2h. Most of the time goes to installing different dependencies for different distros(and versions of these) + solving cryptic erlang errors(once I spent 4h on single db migration error).

Building/deploying further releases/upgrades on small VPS’s is also very very slow(think DO’s $5 droplet).

This is the biggest reason I started using node and go for simple/medium complex projects.

A while ago I also had ansible scripts to set-up everything but these got outdated and created enough additional complexity that made me stop using them. Using hosting services like heroku just for this is also no-go for me or my clients.

Most Liked

tty

tty

I usually make sure my build machine and target server are the same: same OS, same versions of libs.

Then make a Release Package. From there its a straight scp+untar and its up and running.

mythicalprogrammer

mythicalprogrammer

Watch this:

The short answer is in the future, they’re working on it.

pedromvieira

pedromvieira

I used this Guide to start our current deployment Docker / Kubernetes on GCP.
It is really easy and fast to deploy a new build.

zkessin

zkessin

Yes, once you build a release it is pretty easy. I have an email course you can get (its free) on how to do it

https://elixirtraining.org/release_email_course.html

Andrei

Andrei

Hi there

The first time I went to production I can say that it took me some time to take care of everything.
Deploying Elixir/Phoenix apps requires certain OS knowledge.

I have a vagrant box for each project locally. Sure, you can use Docker if you fancy or anyother containerization software however there are some hidden costs to this approach.

I make sure that the VPS OS is the same as the OS I’ll be using in Vagrant. For most projects it’s just copy pasting the vagrant setup file.

Then I’ve created a simple bash script which compiles everything from within a virtual machine with distillery and copies it via SCP, extracts & runs it on the host. (You can compare it to edeliver… however it’s simpler and what I need)

Shouldn’t take more than 10 minutes for the whole compilation stuff. If you use distillery you won’t need to install anything else on the VPS since you’ll get a self contained binary.

I currently run multiple Phoenix/elixir apps on a single Linode VPS. Phoenix gets routed via NGINX on a per domain basis. My usage of nginx is purely based on the fact that I also run some PHP compatible scripts on the same server.
For high performance apps I’d recommend using HAproxy since it goes better AND has more statistics. This way you don’t need to setup 10 vps’es for 10 apps :slight_smile:

The only downside to this is that yes, I need to configure a systemd service manually for each app. Nginx setupalso needs to be defined manually. These happen only the first time. After that it’s just reloading the vagrant box and deploying it.

I’d also recommend something else if you ever have issues with DB migrations. Or if you want to work directly on the remote DB in a secure way, at least for the migration of the data part
This may seem as less good practice from a security standpoint however if you use public key certificates it’s all good . Set up a reverse port forwarding from your production postgresql (or another DB) to your localhost.
This way you can use the remote database locally. All over an encrypted connection and you need not modify anything in postgresql to allow outgoing IP’s since everything will be done via localhost.

ssh -L 40001:localhost:5432 user@remotehost.net -p 2887 

Where localhost is the hostname and 40001 is the local port you’ll use/
The -p 2887 indicates that I’ll be using that port for SSH instead of the default SSH port.

The above can be used for everything else as well including observing your app locally, migration of big data. All from your own box.

Good luck!

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New

We're in Beta

About us Mission Statement