No description
  • Dockerfile 57.9%
  • Shell 42.1%
Find a file
2026-05-15 20:19:04 +05:00
gnu init 2026-05-15 20:19:04 +05:00
musl init 2026-05-15 20:19:04 +05:00
.gitignore init 2026-05-15 20:19:04 +05:00
Makefile.toml init 2026-05-15 20:19:04 +05:00
README.md init 2026-05-15 20:19:04 +05:00

rust-alpine-mimalloc

Just a personal customization of rust-alpine-mimalloc at commit 0f4a745

This Docker image comes with pre-configured targets

  • x86_64-unknown-linux-musl
  • aarch64-unknown-linux-musl

Each of those shall compile with +crt-static, use clang(lld) linker, and musl with mimalloc.

Everything is compiled with static linking by default, feel free to alter rustflags for a specific target.

Usage

Usually don't 😀

However containers are at source.spushk.ru/rustyworks/rust-alpine-mimalloc:<tag>

THIS IMAGE IS FOR BUILDING ONLY

DO NOT - PLEASE - DO NOT USE THIS AS A BASE FOR RT IMAGES

Pre-installed cargo tools:

  • cargo-chef
  • cargo-make

Pre-installed apks:

  • clang-dev
  • cmake
  • make
  • lld
  • libgcc
  • zlib-dev
  • zstd-dev
  • lz4-dev
  • libc-dev
  • openssl-dev
  • protobuf-dev
  • protoc
  • perl
  • binaryen

^ which should suffice for the majority of projects out-of-the-box.

Common pitfalls reminder

Openssl

Avoid openssl as much as possible. Check this:

cargo tree -i openssl cargo tree -i openssl-sys

And search for something like rustls feature flag for causing crates.

Common and known:

reqwest has openssl by default, do this:

reqwest.default-features = false
reqwest.features = ["charset", "http2", "rustls-tls"]

teloxide uses reqwest/openssl by default, do this:

teloxide.default-features = false
teloxide.features = ["ctrlc_handler", "rustls"]

If nothing works

As the last measure explicitly specify the openssl dependency:

openssl.version = "^0.10"
openssl.features = ["vendores"]

Manually build

cd gnu
podman build --target fat-musl -t <NAME> .

Or make sure to have MK_ALPINE_NAME and MK_GNU_NAME env variables to set to your base url (like rust-alpine-mimalloc and rust-gnu)

Then run cargo make build and enjoy having 1.95-slim, 1.95 image tags for both alpine and gnu based images

Original description (for historical reasons only) This Docker image builds upon the `alpine:latest` image, provides `cargo`/`rustc` and replaces the default musl malloc implementation with [`mimalloc`](https://github.com/microsoft/mimalloc). If you build Rust or C/C++ static executables in this image, the resulting executables will automatically link with `mimalloc` without needing any special build flags.

Notice: we switched away from rust:alpine and now uses cargo/rust packaged by alpine. Statically linked executables will continue to link against mimalloc as intended, but you need extra command-line arguments to ensure they are indeed static:

$ cargo install --target x86_64-alpine-linux-musl foo

The --target flag is required. The default target is either x86_64-alpine-linux-musl or aarch64-alpine-linux-musl, and can also be extracted from $(rustc -vV | sed -n "s|host: ||p").

Supported & tested archs: amd64 and arm64/v8.

For more details, see this blog post.

rust-glibc

This repository also provides tools to build trixie-based fat container for building rust with gnu libc.

Use this as the last resort, when you absolutely need GLIBC

The following targets:

  • x86_64-unknown-linux-gnu
  • aarch64-unknown-linux-gnu

Are configured to use mold linker and glib with dynamic linking and builtin malloc.

Pre-installed cargo tools:

  • cargo-make
  • cargo-chef

Pre-installed packages:

  • clang
  • mold
  • cmake
  • make
  • libgcc-13-dev
  • zlib1g-dev
  • libzstd-dev
  • liblz4-dev
  • libc-dev
  • libssl-dev
  • libprotobuf-dev
  • protobuf-compiler
  • perl
  • binaryen

Manually build

cd gnu
podman build --target fat-gnu -t <NAME> .