emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

Set RUSTUP_HOME and CARGO_HOME for building as root #105

Closed gibfahn closed 3 years ago

gibfahn commented 3 years ago

This is the minimal change needed to allow the docker image to be run with --user root and still build correctly.

There may be better long-term ways of doing this, but hopefully this is small enough to be uncontroversial.

This isn't a breaking change for users running normally (as the rust user) because these are already the default paths.

Refs: https://github.com/emk/rust-musl-builder/issues/96 Refs: https://github.com/emk/rust-musl-builder/pull/100

gibfahn commented 3 years ago

I set these vars where the other ENV vars were set. If instead they are set at the start, then the curl https://sh.rustup.rs | sh above would respect them. This doesn't make any difference now as it's the default, and I doubt rustup is going to change its defaults, but seems worth noting.

emk commented 3 years ago

I have merged a slightly different version of this idea. Please let me know if it works for you (assuming you're still using it)!

gibfahn commented 3 years ago

Thanks, replied in https://github.com/emk/rust-musl-builder/issues/96#issuecomment-756466529 to keep the context there.