FROM elixir:latest
WORKDIR /app
RUN mix local.rebar --force && mix local.hex --force
RUN rm -rf deps _build
RUN mix do deps.get, deps.compile
ENV MIX_ENV=prod REPLACE_OS_VARS=true TERM=xterm
CMD ["mix", "release", "--env=prod", "--executable", "--verbose"]
Muhammads-MacBook-Pro:builder Azim$ docker build -t hello-builder .
Sending build context to Docker daemon 4.096kB
Step 1/7 : FROM elixir:latest
---> 46c8f1ed0132
Step 2/7 : WORKDIR /app
---> Using cache
---> 3f18f38e96fb
Step 3/7 : RUN mix local.rebar --force && mix local.hex --force
---> Using cache
---> b3cf53fe75bc
Step 4/7 : RUN rm -rf deps _build
---> Using cache
---> eb87150a83b8
Step 5/7 : RUN mix do deps.get, deps.compile, compile
---> Running in f80f7f74a82a
** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a directory with a mix.exs file
The command '/bin/sh -c mix do deps.get, deps.compile, compile' returned a non-zero code: 1
I notice after I docker run --rm -it -v $(pwd):/app hello-builder it will rebuild _build/prod/rel/hello/bin/hello.run
After it finish building it, I deleted the /tmp folder and try running it locally on my Mac PORT=8080 _build/prod/rel/hello/bin/hello.run foreground
Muhammads-MacBook-Pro:hello Azim$ PORT=8080 _build/prod/rel/hello/bin/hello.run foreground
/Users/Azim/Phoenix/hello/tmp/hello/erts-10.2.1/bin/erl: line 13: /Users/Azim/Phoenix/hello/tmp/hello/erts-10.2.1/bin/erlexec: cannot execute binary file
/Users/Azim/Phoenix/hello/tmp/hello/erts-10.2.1/bin/erl: line 13: /Users/Azim/Phoenix/hello/tmp/hello/erts-10.2.1/bin/erlexec: Undefined error: 0
Unusable Erlang runtime system! This is likely due to being compiled for another system than the host is running
Is that suppose to happen after I build it using docker?
Have you deleted deps before your recent docker run?
This is an important step that you need to do manually before running the docker, since you are using a volume and we can not currently put it in your entry point easily.