使用Mix.release代替distillery

Author:Gao
Created At:2021-10-14

使用Mix.release代替distillery

Elixir在1.9中推出了mix.release功能,来发布OTP版本

由于是语言本身提供的功能,在phoenix中提供了runtime config配置来处理对应参数,相对于distillery开发方便了很多。

简单实用方法:

初始化release

mix release.init

会生成并创建

rel/
  env.bat.eex
  env.sh.eex
  remote.vm.args.eex
  vm.args.eex

mix.exs中添加

def project do
    [
      # ...
      releases: [
        gsmlg_umbrella: [
          applications: [
            gsmlg: :permanent,
            gsmlg_web: :permanent
          ]
        ],
        gsmlg_web_only: [
          applications: [gsmlg_web: :permanent]
        ],
        gsmlg_only: [
          applications: [gsmlg: :permanent]
        ]
      ]
      # ...
    ]
  end

发布版本

MIX_ENV=prod mix release <<release name>>

相对与distillery的不同

相对于distillery配置来说大大的简化了对应的配置

缺点是: 不再支持erlang VM最强大的特性,热更新