Closed jcaesar closed 5 years ago
Thank you! This is good to know.
This is a much better idea, nice contribution. I don't have a .cargo/git
though. I just put this in /usr/local/bin/rust-musl-builder
podman run \
--net host --rm -u root -e HOME=/home/rust/ \
-e LIB_LDFLAGS=-L/usr/lib/x86_64-linux-gnu -e CFLAGS=-I/usr/local/musl/include \
-e CC=musl-gcc -e CXX=musl-g++ \
-v "$HOME/.cargo/registry:/home/rust/.cargo/registry" \
-v "$PWD:/home/rust/src" \
ekidd/rust-musl-builder:nightly cargo build "$@"
I would also suggest adding $@
at the end, I find it useful to call cargo build
with --release
because my Cargo.toml
has specific release stuff.
Make that a "$@"
(Eh, I didn't use -v "$PWD:/home/rust/src"
either. Shame.) and you have me. ;)
(Also, I probably only used --net host
because I wasn't able to get my network settings straight at the time. Shouldn't be necessary.)
Content
I noticed that the caching / volume / UID trouble can be avoided by using podman instead of docker from an unprivileged user
The joke here is that podman remaps 0 to your current user id if you configure
/etc/sub{u,g}id
. There may be more nifty ways of doing this, especially some that do not run cargo as root in the container or require thatHOME=
hack…(
CFLAGS
,LIB_LDFLAGS
,CC
, andCXX
are probably only required because I have rdkafka among my dependencies. I currently have no other testing ground.)Meta
Feel free to immediately close this as a side note, or to ask me for a PR adding it to the Readme or similar…