Release docker & build, NIF for wx not found

After generating a Dockerfile with mix release, and build it with docker build, I am unable to start elixir in the container:

=INFO REPORT==== 15-Dec-2023::08:20:17.080211 ===
    application: kernel
    exited: {{shutdown,
                                 "Failed to load NIF library: '/app/lib/wx-2.3.1/priv/ cannot open shared object file: No such file or directory'"}}}}},
    type: permanent

I am using the generated Dockerfile as is with the following versions:

ARG DEBIAN_VERSION=bullseye-20231009-slim


What is missing here? build and execution on Apple Silicon

1 Like

So in my case, the issue was a dependency which uses

extra_applications: [:logger, :runtime_tools, :wx, :observer]

:wx and :observer removed and the container runs as expected. Unfortunately mix deps.tree does not show such dependencies. To find the one I searched for :wx and :observer in the deps directory. Be aware that in VSCode this folder might be excluded from global search, so use grep or similar form the command line.

For future reference, these applications are part of OTP and are bundled together with erlang runtime, if declared of course.

In earlier versions of elixir, all packages would be usually bundled without having to specifically add them, this changed in version 1.15 (or maybe earlier), now you have to specifically declare them if you want to bundle them with your release.

On the dev side, the libraries will work without adding extra_applications as long as your local erlang installation compiled all of them.

1 Like

With specifically add them you mean also add them to my-app extra_applications?

The behavior you are encountering above might be subject to a potential bug, if either your app or a library has extra_applications defined, the OTP libraries should be bundled with release. I misread before, thinking that you are using those libraries from your own application.

A simple example would be the fact that phoenix uses crypto, which is an OTP library, and you don’t have to declare it in your actual application.

1 Like