After some errors, finally I finished successfully! The point is to use a Docker image of nightly Rust.
- Use nightly and openssl tag of rust-musl-builder image
- I used
nightly-2020-01-26-openssl11
tag just because it's near to our rust-toolechainnightly-2020-01-15
. More later versions might work
- Run bash in container
- Remove rust-toolchain file
- Install gettext package
sudo apt update -y && sudo apt install -y gettext
- Build Plume
cargo build --release --no-default-features --features=postgres --target=x86_64-unknown-linux-musl
I got static build of Plume!
% ldd ./target/x86_64-unknown-linux-musl/release/plume
not a dynamic executable
I hope this may help you.
Ah, more my mistake...
I use these scripts to build binaries:
This means:
- I have not tried to build musl binaries
- But, I use the scripts to build non-static (
x86_64-unknown-linux-gnu
) binaries - I mentioned them just for information because I thought they might help you think how to build musl binaries though they does not build musl binaries themselves
- I din't mean those work for musl target
Step 2/6 : RUN rustup target install x86_64-unknown-linux-musl
You're right. I was wrong.
Step 6/6 : RUN cargo build --release --features="$FEATURES"
What's about to run?
cargo build --release --features="$FEATURES" --target x86_64-unknown-linux-musl
Sorry for my unclear instruction.
If you succeeded to build, it's ok. But if not, I did mean
- keep
rust-toolchain
- move to you Plume directry
- the, run
rustup target install ...
rust-toolchain
specifies a Rust version, not a build target. I guess installing musl target under Plume directory which has rust-tookchain
downloads suitable Rust version for musl target. But I cannot try it because I'm not i front of computer now. Just guessing.
You might have to run cargo install
under Plume directory. Plume project has rust-tookchain
file which specifies Rust version.
I use these scripts to build binaries:
- https://git.joinplu.me/Plume/Plume/src/branch/main/script/prebuild.sh
- https://git.joinplu.me/Plume/Plume/src/branch/main/script/prebuild-in-docker.sh
Do they help you though they use a Debian Docker image?