Mix throw * (ArgumentError) argument error when building phoenix with distillery & docker

I’m building my phoenix project with distillery & docker according to https://hexdocs.pm/distillery/guides/building_in_docker.html#building-releases, but when I run docker run -v $(pwd):/opt/build --rm -it elixir-ubuntu:latest /opt/build/bin/build, I got this:

* creating .mix/rebar
* creating .mix/rebar3
** (ArgumentError) argument error
    (stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:446: :erl_eval.expr/5
    (stdlib) erl_eval.erl:126: :erl_eval.exprs/5
    (elixir) lib/code.ex:232: Code.eval_string/3
    (mix) lib/mix/config.ex:187: anonymous fn/2 in Mix.Config.__import__!/2
    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3

I found that it’s caused by export MIX_ENV=prod. After I remove it, the bash script runs ok.

Also, MIX_ENV=prod mix deps.get would throw same error.

Not sure what’s going on here.

It looks like you may be missing some configuration in your prod.exs config file.

Interesting, you’re right. I have something like port = String.to_integer(System.get_env("PORT")) in prod.exs config, and it’s causing the problem.

The most interesting part is I have many System.get_env() in prod.exs file, only the PORT one is causing problem. Changing to http: [port: {:system, "PORT"}] fix my problem.