找不到Elixir Docker多阶段映像文件

e4yzc0pl  于 2023-08-03  发布在  Docker
关注(0)|答案(1)|浏览(177)

我创建了一个简单的Elixir应用程序,没有Phoenix,我可以在没有Docker的情况下运行它。
当我想使用多阶段构建将应用程序停靠时,我遇到了一个问题

  1. /app/_build/prod/rel/todo_app/releases/0.1.0/../../erts-14.0.2/bin/erl: exec: line 12: /app/_build/prod/rel/todo_app/erts-14.0.2/bin/erlexec: not found

字符串
这里是dockerfile

  1. FROM elixir:1.15.1 as build
  2. ENV MIX_ENV=prod
  3. COPY lib ./lib
  4. COPY mix.exs .
  5. COPY mix.lock .
  6. RUN mix local.hex --force && \
  7. mix local.rebar --force && \
  8. mix deps.get && \
  9. mix release
  10. # Copy the production.env.exs file to the container
  11. COPY config/prod.env.exs config/
  12. # Final stage for the production release
  13. FROM alpine:3.14
  14. RUN apk add --no-cache bash openssl
  15. WORKDIR /app
  16. # Copy the release from the build stage
  17. COPY --from=build . .
  18. # Copy the Erlang runtime files
  19. # COPY --from=build /app/_build/prod/rel/todo_app/erts-* /app/erts/
  20. # Set the environment variables
  21. ENV REPLACE_OS_VARS=true
  22. ENV PORT=80
  23. ENV MIX_ENV=prod
  24. EXPOSE 80
  25. # CMD ["ls", "_build/prod/rel/todo_app/erts-14.0.2/bin"]
  26. CMD ["_build/prod/rel/todo_app/bin/todo_app", "start"]


但当我尝试与单阶段,它是工作。
单级dockerfile

  1. FROM elixir:1.15.1 as builder
  2. WORKDIR /app
  3. COPY . .
  4. ENV MIX_ENV=prod
  5. COPY lib ./lib
  6. COPY mix.exs .
  7. COPY mix.lock .
  8. COPY config/prod.env.exs config/
  9. RUN mix local.rebar --force \
  10. && mix local.hex --force \
  11. && mix deps.get \
  12. && mix release
  13. # ---- Application Stage ----
  14. # RUN apk add --no-cache --update bash openssl
  15. CMD ["_build/prod/rel/todo_app/bin/todo_app", "start"]


帮助我在我的多级dockerfile中出错了。

von4xj4u

von4xj4u1#

如果你想在Alpine上跑步,你也应该在Alpine上跑步。
请尝试FROM elixir:1.15.1-alpine as build
顺便说一下,hexpm imagesmore suitable的Elixir开发比官方图像。

相关问题