Docker image for building static Rust binaries against musl-libc. Includes OpenSSL, libpq, libz, SQLite3 pre-built statically, so crates like diesel, sqlx, and openssl work out of the box.
Images are published as a multi-arch manifest (linux/amd64 + linux/arm64) to ghcr.io/pyar6329/rust-musl-builder/rust-musl-builder. Tags are X.Y.Z-llvm-cov matching the Rust version in rust-toolchain. See the GitHub Container Registry package page for the full tag list.
docker pull ghcr.io/pyar6329/rust-musl-builder/rust-musl-builder:1.95.0-llvm-cov
docker run --rm -it \
-v "$(pwd)":/home/rust/src \
ghcr.io/pyar6329/rust-musl-builder/rust-musl-builder:1.95.0-llvm-cov \
cargo build --releaseBinaries are written to target/<target-triple>/release/. The target defaults to the host architecture (x86_64-unknown-linux-musl on amd64, aarch64-unknown-linux-musl on arm64). To force the other platform, pass --platform=linux/arm64 (or linux/amd64) to docker run.
$(pwd) must be readable/writable by uid/gid 1000.
- Rust toolchain +
rustfmt,clippy,llvm-tools-preview cargo-about,cargo-audit,cargo-deb,cargo-deny,cargo-llvm-covprotoc
If your binary uses OpenSSL, load the host's CA bundle at startup with openssl-probe:
fn main() {
openssl_probe::init_ssl_cert_env_vars();
// ...
}Apache 2.0 or MIT.
Forked from emk/rust-musl-builder.