A new approach to deploying Elixir apps: mix_deploy

By Jake Morrison in DevOps on Tue 18 June 2019

There has been a lot of action lately in Elixir 1.9 to improve the process of generating releases and configuring the system.

I have written two new libraries which which focus on the level below the VM. mix_systemd generates a systemd unit file to run the app, and mix_deploy generates scripts to deploy the app to servers, interface with systemd and the "lifecycle" scripts to work with deployment systems like AWS CodeDeploy.

These libraries are essentially a collection of opinionated templates which work together: they look at the configuration of the app in mix.exs and config/prod.exs and generate a systemd unit file which calls shell scripts.

They also automate the process of managing config files with production secrets, as well as runtime configuration from cloud-init to configure a cluster.

The focus is on three main scenarios:

  1. Building and deploying on the same server
  2. Building on a build system like AWS CodeBuild and deploying to the cloud with a system like AWS CodeDeploy
  3. Building on a CI server and deploying to dedicated servers using Ansible

The same approach scales from a $5/month Digital Ocean server to AWS running a load balancer and autoscaling group, to fleets of dedicated servers.

If you are using containers, then this is not for you. Kubernetes is the up and coming solution, but right now the overhead of getting started is quite high. Elixir's excellent concurrency support means that it works well with a small number of servers with more cores rather than slicing things up into multiple small servers.

Documentation is here:

We have been using these libraries to deploy a number of our production applications. They work fine, but probably have a few rough edges. The goal is that you can simply add the libraries to your project and they will do the right thing, while still being customizable to handle different situations. Please give me your feedback and contributions to cover other scenarios. Biggest issue is support for Elixir 1.9.

I am reachfh on Freenode #elixir-lang IRC channel, jakemorrison on on the Elixir Slack and Discord. I am in Taiwan, though, so look for me in that timezone :-).

<< Back to blog index

Featured posts

Deploying an Elixir app to Digital Ocean with mix_deploy Port forwarding with iptables