[Mix Release] Specify Configs per environment


I am migrating from Distillery to Mix release on Elixir 1.9.2. Distillery had the option to specify the environment for options such as cookie and erl_opts in config.exs. Is it possible to do the same in Mix release as well? If so, how can it be done?


Check out rel/vm.args.eex.

1 Like

Hey apr,

I completed the same migration. As usual the official documentation has a great section about that vm.args and env.sh. The mentioned vm.args.eex will be created by mix release.init. It contains also some description.

So is the idea to read the value of MIX_ENV in rel/vm.args.eex and set the value of the cookie (for instance) accordingly?

This is total up to you. You could do something like:

<%= if Mix.env == :dev do %>
-setcookie aprscookie
<% end %>

You have also the variable @release available. This is a Mix.Release struct.

1 Like

Thanks @corka149, this works well. Another way would be to set the cookie based on Mix.env() in mix.exs itself.