A new approach to deploying Elixir apps: mix_deploy
By DevOps on Tue 07 January 2020in
There has been a lot of action lately in Elixir to integrate releases into the core system and improve the process of configuring the application. We still need, however, some way to deploy the releases into production and pull configuration from the environment.
I have written two new libraries which focus on the level below the Erlang 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 handle the deployment lifecycle of systems like AWS CodeDeploy.
They are used when deploying to virtual machines or dedicated servers, not a container system like Kubernetes.
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 CI system like AWS CodeBuild and deploying to the cloud with a CD 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. It provides a simple and cheap way to get started. Elixir's excellent concurrency support means that it works great with a small number of servers with more cores rather than slicing things up.
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 production applications. 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. Contributions are welcome!
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