Mukulch15

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

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

Mukulch15

Thanks that solved the issue. I am running OSX and both the folders were getting copied.

elchroy

elchroy

Faced this same issue. After adding both deps and _build to .docker-ignore, the problem was solved. Thanks!

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement