How are you doing production deployments?

I just finished setting up my first production Elixir deploy :confetti_ball: so I thought I’d share my approach in case it’s helpful to other beginners, especially those coming from the Ruby world, where there is a widely dominant pattern developed in Capistrano, Mina etc.

Basically I wanted something similarly simple, but more flexible. For context, this is not a mission critical application so I had some room to experiment. I knew I wanted to go with ansible, but mainly because I already had experience with it and I’ve been satisfied. I haven’t properly compared it to other tools though. But its deploy_helper module made it really easy! The result was an extremely small playbook:

Some notes:

  • Requires user with sudo access
  • Uses somewhat awkward script for env management, but I wanted to keep my production env vars in a separate file and this seemed like the easiest way
  • Erlang/Elixir managed with asdf. There were some minor gotchas around setting the PATH properly so these settings were respected by the ansible session
  • Requires a migrate task to use with bin/my_app eval as described here
  • Uses systemd to manage app process

Overall it is not the robust approach and I’m sure I’ll be making improvements. It doesn’t handle server provisioning or separate build environments or anything like that, but it seems to work well as a starting point if you just want to get your app deployed in production to linode etc instance.

3 Likes