Docker image fail : exec format error
Describe the bug On building a Docker container image using alpine and then running image, I'm seeing the following error
Error: Error loading shared library /usr/home/app/node_modules/faiss-node/build/Release/faiss-node.node: Exec format error
| at Object..node (node:internal/modules/cjs/loader:1725:18)
| at Module.load (node:internal/modules/cjs/loader:1313:32)
| at Function._load (node:internal/modules/cjs/loader:1123:12)
| at TracingChannel.traceSync (node:diagnostics_channel:322:14)
| at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
| at Module.require (node:internal/modules/cjs/loader:1335:12)
| at require (node:internal/modules/helpers:136:16)
| at bindings (/usr/home/app/node_modules/bindings/bindings.js:112:48)
| at Object.
Environment:
- Operating system: [e.g. Mac OS ]
- Nodejs Version: [e.g. v22.13.0]
- Package Version: [e.g. v0.5.1]
To Reproduce Steps to reproduce the behavior:
- Create a Express App using faiss node, build a docker image with alpine as the base. 2.Run the Docker Image
Expected behavior On running locally with the project I'm able to run my express server fine but when I containerize it , its failing
This is a classic cross-arch issue—exec format error usually means you're trying to run a binary built for a different architecture than the one in the container. Alpine + Node native bindings (like faiss-node) often fail silently at build time and explode only at runtime.
If you're using a Mac (arm64) to build an image for Alpine (typically x86_64), and not explicitly cross-compiling or emulating, this is expected. node-gyp builds will mismatch binary formats.
We’ve dealt with this exact failure in our own stack and have a working mitigation flow that handles cross-arch builds correctly, even with native FAISS bindings. Let us know if you want the patched approach.
Don't think this project is maintained anymore. You might have more luck with my fork (which also has more features). https://github.com/asilvas/faiss-node