Closed runiq closed 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.
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:/etc/profile.d/cargo.sh
(at least for me)RUSTUP_HOME
would not be set and cargo would complain about not having a default targetx86_64-unknown-linux-musl
target because cargo's default config location is~/.cargo/config
, but we only write our desired build target into~root/.cargo/config
, which is not checked when a non-root user invokes cargoThis 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: