1

我在对我的 rebar3 应用程序进行 dockerizing 时遇到了一些问题。当我尝试运行应用程序(构建后)时,我收到一个错误/prod/bin/prod: line 272: /prod/erts-11.2.2.1/bin/erl: not found

这是我的 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}]}]
        }]}.

这是我的 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"]

你有什么想法可能是问题的根源吗?

4

2 回答 2

2

Erlang 不会编译成二进制文件,您仍然需要 erlang 运行时才能运行应用程序,但您的最终 docker 映像是未安装 erlang 的全新 alpine 安装

于 2021-05-30T10:09:51.730 回答
2

erlang:23docker 容器是基于 debian 的。我怀疑该错误是因为该版本是在 debian 容器上生成但在 alpine 容器上执行的。erlang:23-alpine从-container生成版本。

于 2021-05-30T23:50:38.857 回答