【发布时间】:2020-12-26 23:46:55
【问题描述】:
目标:为了能够跑凤凰,在一个ec2实例中混合发布(本机:https://hub.docker.com/_/amazonlinux/)
问题:运行我的版本会产生以下错误:
/my_app/erts-11.0.3/bin/beam.smp: /lib64/libtinfo.so.6: no version information available (required by /my_app/erts-11.0.3/bin/beam.smp)
2020-09-08 13:17:33.469328
args: [load_failed,"Failed to load NIF library /my_app/lib/crypto-4.7/priv/lib/crypto: 'libcrypto.so.1.1: cannot open shared object file: No such file or directory'","OpenSSL might not format: label: be installed on this system.\n"]
"Unable to load crypto library. Failed with error:~n\"~p, ~s\"~n~s"
{error_logger,error_msg}
但我在每个场景中都安装了openssl (OpenSSL 1.0.2k-fips 26 Jan 2017)。
设置:
我创建了一个新的凤凰项目:
yes | mix phx.new my_app --no-webpack --no-ecto --no-dashboard --no-gettext
cd my_app
并取消注释config/prod.secret.exs 中的config :my_app, MyAppWeb.Endpoint, server: true 行以在运行应用程序时启动服务器。
我创建以下Dockerfile 来构建我的项目:
FROM debian:buster
# Install essential build packages
RUN apt-get update
RUN apt-get install -y wget git locales curl gnupg-agent
# Set locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV HOME=/opt/app
WORKDIR /opt/app
# Install erlang and elixir
RUN wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
RUN dpkg -i erlang-solutions_2.0_all.deb
RUN apt-get update
RUN apt-get install -y esl-erlang
RUN apt-get install -y elixir
# Install hex and rebar
RUN mix do local.hex --force, local.rebar --force
# Install phoenix
RUN mix archive.install hex phx_new 1.5.4 --force
COPY mix.exs mix.lock ./
COPY config config
COPY priv priv
COPY lib lib
RUN mix deps.get
ENV SECRET_KEY_BASE='secretExampleQrzdplBPdbHHhr2bpELjiGVGVqmjvFl2JEXdkyla8l6+b2CCcvs'
ENV MIX_ENV=prod
RUN mix phx.digest
RUN mix compile
RUN mix release
CMD ["_build/prod/rel/my_app/bin/my_app", "start"]
并使用以下方法构建图像:
docker build . -t my_app
我们可以通过以下方式检查一切是否按预期运行:
docker run -p 4000:4000 -i my_app:latest
并访问localhost:4000。
我从构建的 docker 容器中复制 _build/prod/rel/my_app 目录(因为这是我将要传输到我的 ec2 实例的全部内容)。
# list all containers
docker container ls -a
# locate the container with image tag: my_app:latest. It should look like:
# f9c46df97e55 my_app:latest "_build/prod/rel/my_…"
# note the container_id, and copy across the build release
docker cp f9c46df97e55:/opt/app/_build/prod/rel/my_app .
我们创建一个instance.Dockerfile 来运行我们的 ec2 实例的命令:
FROM amazonlinux:latest
COPY my_app my_app
CMD ["my_app/bin/my_app", "start"]
并运行它:
docker build . -f instance.Dockerfile -t my_app_instance && docker run -p 4000:4000 -i my_app_instance:latest
运行失败,报错:
[load_failed,"Failed to 2020-09-08 13:27:49.980715
args: load NIF library /my_app/lib/crypto-4.7/priv/lib/crypt format: label: 2020-09-08 13:27:49.981847 supervisor_report o: 'libcrypto.so.1.1: cannot open shared object file: No such file or directory'","OpenSSL might not be installed on this system.\n"]
"Unable to load crypto library. Failed with error:~n\"~p, ~s\"~n~s"
{error_logger,error_msg}
注意:
我可以使用上述docker build ... && docker run ... 命令在debian:buster 机器上复制错误,但使用此instance.Dockerfile:
FROM debian:buster
RUN apt-get update
RUN apt-get install -y locales
# Set locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
COPY my_app my_app
CMD ["my_app/bin/my_app", "start"]
并通过将RUN apt-get install -y locales 更改为RUN apt-get install -y locales curl 来修复错误。
我在amazonlinux:latest 机器上尝试了yum install curl 和yum install openssl,但仍然遇到同样的错误。
问题:
我应该在哪里寻求进展?这似乎是一个erlang/otp需求问题,但上面几乎不是sscce,所以很难提出。
我一直在努力寻找 apt-get curl 软件包安装的哪些 crypto 或 openssl 库导致错误得到修复。
任何指向特定论坛寻求帮助或下一步尝试什么的指针将不胜感激。
提前感谢您的帮助。
【问题讨论】:
-
我看到您使用 debian docker 映像构建应用程序并部署在基于 CentOS 的 Amazon Linux 上。因此,尝试从 CentOS docker 映像构建应用程序并部署在 Amazon Linux 上。要检查的另一件事是查看 EC2 实例中是否安装了 openssl。
-
所以它正在寻找
libcrypto.so.1.1但找不到它。该文件是否存在于 Amazon Linux docker 实例中的某处?也许它只是在错误的地方寻找它,或者也许您需要不同版本的 openssl 包。 -
@legoscia 我试过openssl11。但是,是的,我认为你对这个问题完全正确
-
@VenkatakumarSrinivasan 我尝试基于 CentOS 构建它,一切正常(稍作调整),感谢您的建议
-
@SamHouston,如果您的软件在运行时需要
libcrypto.so.1.1,您需要从EPEL 7 安装openssl11-libs。
标签: amazon-ec2 erlang elixir erlang-otp elixir-mix