Release and NIF library

Hello !

Mix release with NIF in a containser crashes … I can’t find why.

If I run the project locally (mix phx.serve) it works.
When I build a release locally and run it, it works.
When I copy the locally generated release directory in a Docker container and spin it up, it works.

When I build everything in a Docker container (mix release), it fails with the following error:

=INFO REPORT==== 13-May-2026::10:16:55.060537 ===
    application: kernel
    exited: {{shutdown,
                 {failed_to_start_child,on_load,
                     {on_load_function_failed,'Elixir.MSeed.NIF',
                         {error,
                             {bad_lib,
                                 "Failed to find library init function: '/app/wsdataselect/lib/wsdataselect-1.1.18/priv/libexmseed.so: undefined symbol: _nif_init'"}}}}},
             {kernel,start,[normal,[]]}}
    type: permanent

Kernel pid terminated (application_controller) ("{application_start_failure,kernel,{{shutdown,{failed_to_start_child,on_load,{on_load_function_failed,'Elixir.MSeed.NIF',{error,{bad_lib,\"Failed to find library init function: '/app/wsdataselect/lib/wsdataselect-1.1.18/priv/libexmseed.so: undefined symbol: _nif_init'\"}}}}},{kernel,start,[normal,[]]}}}")

ldd on the /app/wsdataselect/lib/wsdataselect-1.1.18/priv/libexmseed.so says everything is statically linked.

Dockerfile Dockerfile · 65-libmseed-nif · OSUG / RESIF / wsdataselect · GitLab

Anybody has an idea what is missing in the container ?

Are you cross compiling or is the container the same architecture?

Statically linked on a shared object? That feels kind of wrong. Can you provide a project that we can use to reproduce the problem?

By iterating over a naive Dockerfile until the release breaks, I identified the missing part in the docker context (I omitted to put the ./c directory). Weirdly, the compilation worked, but the release missed all the NIF part.

The fix: Add missing directory in build context (afa04fb3) · Commits · OSUG / RESIF / wsdataselect · GitLab

Thanks for the replies !