clux / muslrust

Docker environment for building musl based static linux rust binaries
MIT License
965 stars 88 forks source link

fix: Unify `root` and non-root user behavior #101

Closed runiq closed 2 years ago

runiq commented 2 years ago

This makes building as root and as a non-root user behave the same.

Before, building as a non-root user (i.e., via podman run --userns=keep-id) would be different in the following ways:

This PR fixes all that by configuring all those settings as environment variables instead. It also sets the cargo PATH via an environment variable, so /etc/profile.d/cargo.sh is not needed anymore.

A downside of this approach is that the build target triple cannot be overridden via config files because the CARGO_BUILD_TARGET environment variable has higher precedence than a ~/.cargo/config entry. I figured this would be fine since the entire point of this project is to build against that specific target triple. :upside_down_face:

clux commented 2 years ago

Hey, thanks for this. Yeah, I think this is a slightly better setup as well.

A downside of this approach is that the build target triple cannot be overridden via config files because the CARGO_BUILD_TARGET environment variable has higher precedence than a ~/.cargo/config entry. I figured this would be fine since the entire point of this project is to build against that specific target triple.

Yeah, I would be surprised if there are anyone overriding it in this image, but we'll see. At any rate, I think it's ok to make this change.