Hi,
I've written a javascript and rust app using Neon which works when running on my development mac. When i try and run the software in a production docker image based on either the ubuntu:latest or rust images then the app crashes with the error:
Error: /native/index.node: invalid ELF header
I wonder if anyone could help but letting me know why i'm getting this error when running in a production docker image.
Thank you.
This sounds like it's attempting to use the binary that was built for macOS in Linux. I recommend adding the built stuff from gitignore (e.g., native/target) to your dockerignore file and doing a clean build in the docker build/container.
Thanks for that. I did give that a try but came across another error. I've installed nodejs npm rust and neon on my docker image but when i run neon build in my docker image to build a fresh i get a new error which says that rust is not installed or the Path for rustc is not correct. I'm sure its installing properly as after the curl command it gives the message installed stable rust.
I've had that same problem. You can set the cargo path and that might help.
ENV PATH=/usr/local/cargo/bin:$PATH
If I get a chance, I'll add a Dockerfile to a sample neon project as an example.
@dherman Would you be interested in having official neon docker images? I could probably maintain them.
@PSPanesar I uploaded an example Dockerfile. It has some deficiencies that I would recommend fixing for production (e.g., running as root), but should be enough to demonstrate the idea.
https://github.com/kjvalencik/neon-example/commit/ea19def42b83a41e641151b491eade6b4a999896
Hi, Thanks for that. I'll test out the dockerfile with my build. I did add the cargo path as above but it didn't solve my problem initially. I'll give your dockerfile a try though thanks.
Most helpful comment
I've had that same problem. You can set the cargo path and that might help.
If I get a chance, I'll add a
Dockerfileto a sample neon project as an example.@dherman Would you be interested in having official neon docker images? I could probably maintain them.