Deploying with Mix

The emergence of deployment tools within git and Elixir’s basic tooling makes it pretty simple to stand up a dead-simple deployment strategy for a single machine. The easiest way to run an Elixir application in production is by fetching or pushing the source code to your servers and calling:

 $ ​​MIX_ENV=prod​​ ​​mix​​ ​​run​​ ​​--no-halt

mix run will compile and start the current application and all of its dependencies. --no-halt guarantees Elixir won’t terminate just after the application is booted. Phoenix is similar. Instead of mix run --no-halt, you will execute mix phx.server, still setting the Mix environment to “prod”.

MIX_ENV=prod ensures your application is running in the production environment with the relevant ...

Get Adopting Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.