Skip to content

pyar6329/rust-musl-builder

 
 

Repository files navigation

rust-musl-builder

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.

Usage

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 --release

Binaries 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.

Included tools

OpenSSL certificates

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();
    // ...
}

License

Apache 2.0 or MIT.

Forked from emk/rust-musl-builder.

About

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Dockerfile 86.5%
  • Shell 7.1%
  • Makefile 6.4%