Umbrella app distillery release dockerised but crashing out

Hello everyone, please can anyone help? I have an umbrella app, which has some Phoenix apps inside the apps folder. The frontend and the api backend. When I use distillery and docker to make a build and then a release, I run the docker container, it fires up. It starts the ejabberd server which I have embedded inside the api backend umbrella app. However one of the Phoenix apps dinarly-api crashes out when I run the docker container and says the following message…

=CRASH REPORT==== 30-Jul-2018::15:19:31 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.2518.0>
    registered_name: []
    exception exit: {bad_return,
                        {{'Elixir.DinarlyApi.Application',start,[normal,[]]},
                         {'EXIT',
                             {undef,
                                 [{'Elixir.DinarlyApi.Application',start,
                                      [normal,[]],
                                      []},
                                  {application_master,start_it_old,4,
                                      [{file,"application_master.erl"},
                                       {line,273}]}]}}}}
      in function  application_master:init/4 (application_master.erl, line 134)
    ancestors: [<0.2517.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.2519.0>,normal}]
    links: [<0.2517.0>,<0.1885.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 201
  neighbours:
15:19:31.678 [info] Application dinarly_api exited: exited in: DinarlyApi.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function DinarlyApi.Application.start/2 is undefined (module DinarlyApi.Application is not available)
            DinarlyApi.Application.start(:normal, [])
            (kernel) application_master.erl:273: :application_master.start_it_old/4
15:19:31.694 [info] Stop accepting TCP connections at 0.0.0.0:5222 for ejabberd_c2s
15:19:31.694 [info] Stop accepting TCP connections at 0.0.0.0:5269 for ejabberd_s2s_in
15:19:31.695 [info] Stop accepting TCP connections at 0.0.0.0:5280 for ejabberd_http
15:19:31.712 [info] ejabberd 18.6.0 is stopped in the node 'dinarly@127.0.0.1'
[os_mon] memory supervisor port (memsup): Erlang has closed
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
{"Kernel pid terminated",application_controller,"{application_start_failure,dinarly_api,{bad_return,{{'Elixir.DinarlyApi.Application',start,[normal,[]]},{'EXIT',{undef,[{'Elixir.DinarlyApi.Application',start,[normal,[]],[]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,dinarly_api,{bad_return,{{'Elixir.DinarlyApi.Application',start,[normal,[]]},{'EXIT',{undef,[{'Elixir.DinarlyApi.Application'

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

Although, the release works fine on my Linux desktop and MacBook Pro. Just when I dockerise this release it won’t fire up properly. It’s the Phoenix app in particular which it says that Application.start/2 is undefined. I have Googled this over the past few days in the evenings but have not managed to solve it yet!

Can you show your dockerfile? That might provide more information for someone to solve this.

Sure thing, my two Dockerfiles which are for the build and the release are as follows:

Dockerfile.build

FROM elixir:1.6.5

ENV HOME=/opt/app/ TERM=xterm

RUN mix local.hex --force && \
    mix local.rebar --force

WORKDIR /opt/app
ENV MIX_ENV=prod REPLACE_OS_VARS=true

COPY config/ $HOME/config/
COPY rel/config.exs $HOME/rel/
COPY mix.exs mix.lock ./
COPY apps/dinarly_api/mix.exs $HOME/apps/dinarly_api/
COPY apps/dinarly_api/config/ $HOME/apps/dinarly_api/config/
COPY apps/dinarly_armory_frontend/mix.exs $HOME/apps/dinarly_armory_frontend/
COPY apps/dinarly_armory_frontend/config/ $HOME/apps/dinarly_armory_frontend/config/
COPY apps/dinarly_fikrly_frontend/mix.exs $HOME/apps/dinarly_fikrly_frontend/
COPY apps/dinarly_fikrly_frontend/config/ $HOME/apps/dinarly_fikrly_frontend/config/
RUN mix deps.get
COPY config ./config
RUN mix deps.compile

RUN MIX_ENV=prod mix release --env=prod  --verbose

Dockerfile.release

FROM elixir:1.6.5

EXPOSE 4000
EXPOSE 4001
EXPOSE 5000
EXPOSE 5222
EXPOSE 5269
EXPOSE 5280

ENV MIX_ENV=prod REPLACE_OS_VARS=true SHELL=/bin/bash

WORKDIR /dinarly
COPY ./dinarly.tar.gz ./
RUN tar xfz dinarly.tar.gz

ENTRYPOINT ["bin/dinarly"]

The thing I find strange is that basically the Docker containers build fine, the build and the release, both build okay. The distillery release works fine also outside of Docker. So I am thinking it might be something to do with the Docker container itself. Maybe I need to change that Docker release file?

I have solved this issue now!

I needed to add the following to the bottom of my Docker.release file:

CMD ["foreground"]
1 Like