bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 397 forks source link

deploying with docker with exleveldb included - crash #547

Closed whitered closed 5 years ago

whitered commented 5 years ago

Here is a very simple app that only uses exleveldb library - https://github.com/whitered/distillery-docker

I'm trying to run a docker image following this guide: https://hexdocs.pm/distillery/guides/working_with_docker.html

make docker.build docker.run

The app in the docker container crashes with following log:

2018-09-26 12:47:58.091986 supervisor_report   #{label=>{supervisor,start_error},report=>[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{on_load_function_failed,eleveldb}},{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}]}]}
2018-09-26 12:47:58.092106 crash_report        #{label=>{proc_lib,crash},report=>[[{initial_call,{supervisor,kernel,['Argument__1']}},{pid,<0.726.0>},{registered_name,[]},{error_info,{exit,{on_load_function_failed,eleveldb},[{init,run_on_load_handlers,0,[]},{kernel,init,1,[{file,"kernel.erl"},{line,212}]},{supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[kernel_sup,<0.698.0>]},{message_queue_len,0},{messages,[]},{links,[<0.700.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,273}],[]]}
2018-09-26 12:47:59.094566 crash_report        #{label=>{proc_lib,crash},report=>[[{initial_call,{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.697.0>},{registered_name,[]},{error_info,{exit,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,eleveldb}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,138}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[<0.696.0>]},{message_queue_len,1},{messages,[{'EXIT',<0.698.0>,normal}]},{links,[<0.696.0>,<0.694.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,193}],[]]}
2018-09-26 12:47:59.094848 std_info            #{label=>{application_controller,exit},report=>[{application,kernel},{exited,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,eleveldb}}},{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,eleveldb}}},{kernel,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,eleveldb}}},{kernel,start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done
make: *** [docker.run] Error 1
bitwalker commented 5 years ago

This almost certainly occurs because exleveldb uses a NIF, which is not being recompiled once the object file is built on the host (i.e. you fetch deps and compile on the host, then try to build and run with docker, the latter build does not recompile the NIF). You can address this by adding the _build and deps directories to .dockerignore in the root of the project, or for a more specific fix for exleveldb, you could add the deps/exleveldb/priv directory to .dockerignore (assuming that is where the object files for the NIF are compiled to).

whitered commented 5 years ago

I've tried this and it didn't help. Also I have mix deps.clean --all in the dockerfile

https://github.com/whitered/distillery-docker/commit/a21059c6b9d71bec2bd940ea304fb1bd3644b14b