Mukulch15
Bcrypt failing when running an elixir app inside Dokcer
I have the following dockerfile for an elixir app.
FROM elixir:1.8.1-alpine as builder
RUN apk update && \
apk add git make alpine-sdk
COPY . .
RUN mix local.hex --force && \
mix local.rebar --force
ENV MIX_ENV=prod
RUN mix deps.get && \
mix compile
RUN mix release
FROM alpine:latest
ENV REPLACE_OS_VARS=true
RUN apk --no-cache add ca-certificates bash openssl
COPY --from=builder _build/prod/rel/app/releases/0.0.1/app.tar.gz .
RUN tar xzvf app.tar.gz && rm -rf app.tar.gz
CMD ["bin/app", "console" ]
Docker build is working fine however when I try to run the image I get the following error
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,'Elixir.Bcrypt.Base'}}},{kernel,start,[normal,[]]}}}"}
Thanks
Marked As Solved
NobbZ
Are deps and _build part of your .dockerignore or are they copied into the container?
If they get copied into the container, then :bcrypt_elixirs NIFs won’t get recompiled and those compiled for your host system will get compiled into the release, which again can not work with the libmusl based alpine linux, as your host probably links against libc.
Also Liked
Mukulch15
Thanks that solved the issue. I am running OSX and both the folders were getting copied.
elchroy
Faced this same issue. After adding both deps and _build to .docker-ignore, the problem was solved. Thanks!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









