papercups icon indicating copy to clipboard operation
papercups copied to clipboard

Docker error Config provider Config.Reader failed module Mix is not available

Open aboutphilippe opened this issue 3 years ago • 4 comments

Describe the bug When running docker compose, the docker image returns an error

To Reproduce Steps to reproduce the behavior:

docker compose up of https://github.com/papercups-io/papercups/blob/master/docker-compose.prod.yml

version: "3.2" services: papercups: image: papercups/papercups:latest ports: - "3000:3000" - "4000:4000" command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && echo 'running' && /entrypoint.sh run" depends_on: - db environment: DATABASE_URL: "ecto://postgres:postgres@db/postgres" # PUT YOUR OWN SECRET KEYBASE HERE (MUST BE AT LEAST 64 BYTES) SECRET_KEY_BASE: "dvPPvOjpgX2Wk8Y3ONrqWsgM9ZtU4sSrs4l/5CFD1sLm4H+CjLU+EidjNGuSz7bz" BACKEND_URL: "localhost" MIX_ENV: "prod" REQUIRE_DB_SSL: "false" REACT_APP_FILE_UPLOADS_ENABLED: 1 # Replace with your domain name REACT_APP_URL: "app.papercups.io" db: image: postgres:alpine container_name: papercups ports: - "5432:5432" environment: POSTGRES_PASSWORD: postgres

See error

` ERROR! Config provider Config.Reader failed with: ** (UndefinedFunctionError) function Mix.env/0 is undefined (module Mix is not available) Mix.env() (stdlib 3.14) erl_eval.erl:680: :erl_eval.do_apply/6 (stdlib 3.14) erl_eval.erl:888: :erl_eval.expr_list/6 (stdlib 3.14) erl_eval.erl:240: :erl_eval.expr/5 (stdlib 3.14) erl_eval.erl:232: :erl_eval.expr/5 (stdlib 3.14) erl_eval.erl:233: :erl_eval.expr/5 (stdlib 3.14) erl_eval.erl:888: :erl_eval.expr_list/6 (stdlib 3.14) erl_eval.erl:411: :erl_eval.expr/5

{"init terminating in do_boot",{undef,[{'Elixir.Mix',env,[],[]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]},{erl_eval,expr_list,6,[{file,"erl_eval.erl"},{line,888}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,240}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,232}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,233}]},{erl_eval,expr_list,6,[{file,"erl_eval.erl"},{line,888}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,411}]}]}} init terminating in do_boot ({undef,[{Elixir.Mix,env,[],[]},{erl_eval,do_apply,6,[{},{}]},{erl_eval,expr_list,6,[{},{}]},{erl_eval,expr,5,[{},{}]},{erl_eval,expr,5,[{},{}]},{erl_eval,expr,5,[{

Crash dump is being written to: erl_crash.dump...done `

aboutphilippe avatar Jun 29 '21 00:06 aboutphilippe

Same thing happens if simply running the following command

docker run -e DATABASE_URL="ecto://postgres:postgres@db/postgres" -e SECRET_KEY_BASE="dvPPvOjpgX2Wk8Y3ONrqWsgM9ZtU4sSrs4l/5CFD1sLm4H+CjLU+EidjNGuSz7bz" -e BACKEND_URL="localhost" papercups/papercups:latest

aboutphilippe avatar Jun 29 '21 00:06 aboutphilippe

This has been introduced by 4dcaa5d44a6e69a1fed0b2ffe8392499f3af8b9f, specifically with the following line: https://github.com/papercups-io/papercups/blob/692b2abae0f96f57f2e285f979b10bfe70127dcc/config/runtime.exs#L168

Mix.env() should not be used at runtime, see https://hexdocs.pm/mix/1.12/Mix.html#env/0

As a workaround you can remove the following lines and build the Docker image yourself: https://github.com/papercups-io/papercups/blob/692b2abae0f96f57f2e285f979b10bfe70127dcc/config/runtime.exs#L164-L169

paescuj avatar Jul 06 '21 09:07 paescuj

Thanks @paescuj

I have built a docker image following your suggestion and it worked.

I am not familiar enough with Elixir.. would it require a refactor of that part? In the meanwhile, I forked the repo and added an if statement to make the appsignal configuration optional. I've made the following pull request accordingly : https://github.com/papercups-io/papercups/pull/904.

aboutphilippe avatar Jul 06 '21 17:07 aboutphilippe

@aboutphilippe I'm also not very familiar with Elixir and I don't know what the exact intention is regarding AppSignal. So, I think the best thing would be to let the maintainers fix this issue accordingly.

paescuj avatar Jul 07 '21 07:07 paescuj