dockererlangrebar3

How to dockerize rebar3-erlang application?


I have encountered some problems with dockerizing my rebar3 app. As I'm trying to run the app (after building) I receive an error /prod/bin/prod: line 272: /prod/erts-11.2.2.1/bin/erl: not found

This is my rebar.config:

{plugins, [rebar3_hex]}.
{deps, [
  {cowboy, "2.6.0"},
  {eredis, "1.3.3"},
  {hackney, "1.17.4"},
  {jiffy, "1.0.8"}
]}.

{shell, [
  % {config, "config/sys.config"},
    {apps, [gmm]}
]}.

{relx, [
    {release, {prod, "0.0.1"}, [
        sasl,
        gmm
    ]}
]}.

{profiles, [{prod, [{relx, [
                {dev_mode, false},
                {include_erts, true},
                {include_src, false},
                {debug_info, strip}]}]
        }]}.

And this is my Dockerfile

FROM erlang:23

RUN mkdir /buildroot
WORKDIR /buildroot

COPY src src/
COPY include include/
COPY rebar.config .
RUN rebar3 as prod release

FROM alpine

RUN apk add --no-cache openssl && \
    apk add --no-cache ncurses-libs

COPY --from=0 /buildroot/_build/prod/rel/prod /prod

EXPOSE 8080
CMD ["/prod/bin/prod", "console"]

Do you have any ideas what might be the source of the problem?


Solution

  • erlang:23 docker container is debian-based. I suspect that error is because the release is generated on a debian container but executed on an alpine container. Generate the release from erlang:23-alpine-container.