Plugins are how you extend distillery itself during release generation. It is worth your time to review the module documentation for Mix.Releases.Plugin for more detailed information, including an example plugin.

Plugins can be defined as either a part of your application code, or in Elixir modules contained in .exs files under rel/plugins. The latter will be automatically imported for you so that you can reference them in the configuration.

You add plugins to a release or environment like so:

environment :prod do
  plugin MyApp.ProdPlugin

release :myapp do
  plugin MyApp.DoStuff

Plugins can be configured by passing options to the plugin macro:

plugin MyApp.AwesomePlugin, foo: 1, bar: 2

These plugins are expected to adhere to the Mix.Releases.Plugin behaviour.


Executed prior to the release being assembled. Use this to generate files, etc. before the release process begins. This callback receives a Release struct, fully configured and options.


Executed after the release is assembled in output_dir, but prior to being archived. Useful if you want to manipulate the release in some way after assembly. This callback also receives a Release struct and options.


Executed just prior to archival of the release. Useful for adding things to the release which are not trivially done with overlays. This callback also receives a Release struct and options.


Executed after the release has been archived. Useful for doing post-processing type events, i.e. building a Docker image, etc. Could also be used to automate deployments.


Executed after a release has been cleaned. Useful if your plugin needs to clean up files which may not have been removed by the primary clean task. This callback will receive a list of strings, which are the arguments as passed to mix clean on the command line, unprocessed so that you can pass them to OptionParser and options.