Using Distillery
Learn and practice distillery in this lesson.
We'll cover the following...
What is Distillery?
We’re going to use a release tool called Distillery. From the readme file:
“Distillery takes your Mix project and produces an Erlang/OTP release, a distilled form of your raw application’s components; a single package which can be deployed anywhere, independently of an Erlang/Elixir installation. No dependencies, no hassle.”
A sample project
Let’s walk through building a release for a new project using Distillery.
First, start with mix
to set up a new project:
mix new sample
Then, add :distillery
under your dependencies in the mix.exs
file like this:
def deps do[{:distillery, "~> 2.1"}]end
Don’t worry, we have already made a project for you and added the dependency as well.
Let’s see how Distillery works. Please follow the steps written below to run the program.
defmodule Sample.MixProject do use Mix.Project def project do [ app: :sample, version: "0.1.0", elixir: "~> 1.12", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ {:distillery, "~> 2.1"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end end
Similar to Mix, releases have different environments.
- For
:dev
, Distillery setsdev_mode
totrue
, which supports code reloading for Phoenix and Nerves applications, and setsinclude_erts