Distillery compiling release in docker Comeonin.Bcrypt not working

Hi, I’ve got VPS with Arch Linux and docker container with Arch Linux. I compile my release in container and then try to run it on my VPS. It all works good, but not for Comeonin.

bcrypt_nif.so compiled on vps works but bcrypt_nif.so compiled in docker image does not work, i get errors like

Sep 12 10:15:50 my.vps.net start.sh[17226]: 2016-09-12 10:15:50 crash_report
Sep 12 10:15:50 my.vps.net start.sh[17226]:     initial_call: {supervisor,kernel,['Argument__1']}
Sep 12 10:15:50 my.vps.net start.sh[17226]:     pid: <0.1053.0>
Sep 12 10:15:50 my.vps.net start.sh[17226]:     registered_name: []
Sep 12 10:15:50 my.vps.net start.sh[17226]:     error_info: {exit,{on_load_function_failed,'Elixir.Comeonin.Bcrypt'},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,352}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
Sep 12 10:15:50 my.vps.net start.sh[17226]:     ancestors: [kernel_sup,<0.1031.0>]
Sep 12 10:15:50 my.vps.net start.sh[17226]:     messages: []
Sep 12 10:15:50 my.vps.net start.sh[17226]:     links: [<0.1032.0>]
Sep 12 10:15:50 my.vps.net start.sh[17226]:     dictionary: []
Sep 12 10:15:50 my.vps.net start.sh[17226]:     trap_exit: true
Sep 12 10:15:50 my.vps.net start.sh[17226]:     status: running
Sep 12 10:15:50 my.vps.net start.sh[17226]:     heap_size: 376
Sep 12 10:15:50 my.vps.net start.sh[17226]:     stack_size: 27
Sep 12 10:15:50 my.vps.net start.sh[17226]:     reductions: 117
Sep 12 10:15:50 my.vps.net start.sh[17226]: 2016-09-12 10:15:50 supervisor_report
Sep 12 10:15:50 my.vps.net start.sh[17226]:     supervisor: {local,kernel_sup}
Sep 12 10:15:50 my.vps.net start.sh[17226]:     errorContext: start_error
Sep 12 10:15:50 my.vps.net start.sh[17226]:     reason: {on_load_function_failed,'Elixir.Comeonin.Bcrypt'}
Sep 12 10:15:50 my.vps.net start.sh[17226]:     offender: [{pid,undefined},{id,kernel_safe_sup},{mfargs,{supervisor,start_link,[{local,kernel_safe_sup},kernel,safe]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]

Here: https://www.dropbox.com/sh/eykkkk8i2oxxumg/AAANPyaAyrMb8OqFuF_MSMjHa?dl=0 are those two bcrypt.so files, can anyone tell me what is the difference between them?

I’m at complete loss, because other than that file, everything works :confused:

3 Likes

Ok, i solved my problem. I had garbage leftovers from first tries of deploying in my local _build + rel directories, and also garbage in deployment directories on my VPS. Somewhere along the way either docker picked garbage, or my deployment did not overwritten garbage on VPS.

Remember kids, when things go highwire clean your environments :wink:

PS. Marking as solved, maybe it’l help someone.

3 Likes

You’re lucky, i’ve tried to do the same but no luck, I’m creating a distillery release within alpine linux and also trying to run in on the same image, I basically run docker run -ti -v `pwd`:/tmp/project -w /tmp/project alpine:edge /tmp/project/release.sh where release.sh is

apk --update --no-cache add elixir erlang-crypto erlang-xmerl erlang-syntax-tools git make

mix local.hex --force
mix local.rebar --force

export MIX_ENV=prod
mix compile
mix release --env=prod --name=client

and then I create my docker image using this dockerfile

RUN apk --update --no-cache add elixir erlang-crypto erlang-xmerl erlang-syntax-tools

ENV PORT=80 MIX_ENV=prod
EXPOSE $PORT

RUN mkdir /app
WORKDIR /app

COPY ./_build/prod/rel/client/releases/0.1.0/client.tar.gz /tmp/build.tar.gz

RUN tar xvf /tmp/build.tar.gz

CMD bin/client foreground

however on start it has the same error :confused:

2 Likes

Oh found it, I had cleared only the _build folder, not deps, damn it :slight_smile:

UPDATE: spoke too soon, still same issue :confused:

2 Likes

Hmm… Are you getting your mix.deps inside the docker build container, or coping them from local dev environment? If it’s the latter that’s why it’s failing. Try mix reps clean from local dev environment, and also add mix deps get to docker build file. And see what’s happen.

PS. I’m on the phone and can’t check now my docker scripts.

UPDATE: I checked repo of that project and it seems i don’t have those docker scripts to build it, because since last year I started to simply build and compile my apps on target machines. Less hassle, and those are not some critical apps anyway. Sorry :confused:

3 Likes

I’m running into the same error, except I’m not deploying with docker anywhere.

Building releases on OSX, and sending over the releases to an ubuntu machine. But each time I try to run it, I get this same

reason: {on_load_function_failed,'Elixir.Comeonin.Bcrypt'}

error. :persevere:

1 Like

Interesting… I may have been missing erlang-crypto. But now I’m getting this error:

sudo PORT=80 ./bin/app foreground
{"init terminating in do_boot",{load_failed,[asn1rt_nif,asn1rt]}}
init terminating in do_boot ()

Crash dump is being written to: erl_crash.dump...done

Shutting down..
Node is not running!

What’s the minimum hardware requirements to run a phoenix app? I was under the impression that it was very light weight…

1 Like

You can’t build a release on one OS and run it on another with NIFs, unless you are cross compiling the NIFs. The same applies if you are including ERTS. Your build environment has to match the target system.

8 Likes

Thanks bitwalker,

I must of missed the bit about NIFs in the docs. Finally got around to trying it again today and got it deployed.

1 Like