简体   繁体   English

如何码头化 rebar3-erlang 应用程序?

[英]How to dockerize rebar3-erlang application?

I have encountered some problems with dockerizing my rebar3 app.我在对我的 rebar3 应用程序进行 dockerizing 时遇到了一些问题。 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当我尝试运行应用程序(构建后)时,我收到错误/prod/bin/prod: line 272: /prod/erts-11.2.2.1/bin/erl: not found

This is my rebar.config:这是我的 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这是我的 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?你有什么想法可能是问题的根源吗?

Erlang does not compile into binary files, you still need the erlang runtime to be able to run the application, yet your final docker image is a fresh alpine install that doesn't have erlang installed Erlang does not compile into binary files, you still need the erlang runtime to be able to run the application, yet your final docker image is a fresh alpine install that doesn't have erlang installed

erlang:23 docker container is debian-based. erlang:23 docker 容器是基于 debian 的。 I suspect that error is because the release is generated on a debian container but executed on an alpine container.我怀疑该错误是因为该版本是在 debian 容器上生成的,但在 alpine 容器上执行。 Generate the release from erlang:23-alpine -container.erlang:23-alpine生成版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM