A new approach to deploying Elixir apps: mix_deploy
By DevOps on Tue 18 June 2019in
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 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
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
The focus is on three main scenarios:
- Building and deploying on the same server
- Building on a build system like AWS CodeBuild and deploying to the cloud with a system like AWS CodeDeploy
- 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:
- mix_systemd GitHub project
- mix_deploy GitHub project
- A complete sample app
- A step by step tutorial for beginners: Deploying an Elixir app to Digital Ocean with mix_deploy
- Deploying Elixir apps with Ansible
- Best practices for deploying Elixir apps
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.
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