Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling rustler on Docker Alpine #296

Closed
simonprev opened this issue Jan 17, 2020 · 4 comments
Closed

Compiling rustler on Docker Alpine #296

simonprev opened this issue Jan 17, 2020 · 4 comments

Comments

@simonprev
Copy link

I’ve been trying to deploy an Elixir app with a rustler based module. Everything works fine in development but when I try to build the docker image on Alpine, I have this error:

Compiling NIF crate :nifty_graph (native/nifty_graph)...
    Updating crates.io index
    Updating git repository `https://github.com/rusterlium/rustler`
 Downloading crates ...
  Downloaded unreachable v1.0.0
  Downloaded quote v1.0.2
  Downloaded which v3.1.0
  Downloaded petgraph v0.5.0
  Downloaded heck v0.3.1
  Downloaded lazy_static v1.4.0
  Downloaded syn v1.0.13
  Downloaded proc-macro2 v1.0.7
  Downloaded indexmap v1.3.1
  Downloaded failure v0.1.6
  Downloaded fixedbitset v0.2.0
  Downloaded libc v0.2.66
  Downloaded unicode-xid v0.2.0
  Downloaded unicode-segmentation v1.6.0
  Downloaded void v1.0.2
  Downloaded autocfg v1.0.0
  Downloaded backtrace v0.3.42
  Downloaded rustc-demangle v0.1.16
  Downloaded cfg-if v0.1.10
  Downloaded backtrace-sys v0.1.32
  Downloaded cc v1.0.50
error: cannot produce dylib for `nifty_graph v0.1.0 (/build/native/nifty_graph)` as the target `x86_64-unknown-linux-musl` does not support these crate types
** (RuntimeError) Rust NIF compile error (rustc exit code 101)

This seems to be a known issue of Alpine, but can you guide me on possible solution on building a docker container with a rust dependency?

Thank you!

@gcauchon
Copy link

For what it’s worth, I created a simple repo to reproduce the issue…

https://github.com/gcauchon/rustler-alpine

That’s about as far as my rust skills can go!

@hansihe
Copy link
Member

hansihe commented Jan 20, 2020

This seems to be the issue you are hitting rust-lang/cargo#7563

Does anything in there help?

@gcauchon
Copy link

Does anything in there help?

It did more than help; it fixed the issue: https://github.com/gcauchon/rustler-alpine#solution

🍻 @hansihe

@evnu
Copy link
Member

evnu commented Jan 28, 2020

To conclude, building on alpine works when build-base is installed and the target-feature=-crt-static flag is used:

RUSTFLAGS='--codegen target-feature=-crt-static'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants