Neon: Error: /native/index.node: invalid ELF header error when running in docker image

Created on 3 Jun 2018  路  5Comments  路  Source: neon-bindings/neon

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.

Most helpful comment

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hardliner66 picture hardliner66  路  3Comments

leshow picture leshow  路  3Comments

vasishath picture vasishath  路  3Comments

crazyfrozenpenguin picture crazyfrozenpenguin  路  3Comments

ZhangHanDong picture ZhangHanDong  路  5Comments