kgrv/rust

By kgrv

Updated 17 days ago

A mimalloc static compiled Rust toolchain for amd64 and arm64.

Image
Languages & frameworks
0

2.5K

kgrv/rust repository overview

DESCRIPTION

A mimalloc static compiled rust toolchain for amd64 and arm64.

SUPPORTED TAGS

SUPPORTED ARCHITECTURES

OS/ARCHDescription
linux/amd6464-bit x86 architecture for Linux operating systems
linux/arm6464-bit ARM architecture for Linux operating systems

PARAMETERS

TypeContainerFunction
EnvironmentEUIDOptional Effective User ID
EnvironmentEGIDOptional Effective Group ID
EnvironmentUMASKOptional Default permissions
EnvironmentSUGGESTOptional Set suggestion messages
Volume/mntOptional Bind mount volume

OVERVIEW

Note

Rust statically links all but glibc.

Based on kgrv/toolchain:clang

Static Compilation

Available cargo targets:

  • aarch64-alpine-linux-musl
  • x86_64-alpine-linux-musl

Mimalloc

  • musl struggles with multi-threaded performance compared to glibc
  • mimalloc patched libc.a to replace musl malloc

User / Group ID

  • EUID / EGID environment variables
  • mini:mini as default

Mask

  • UMASK defaults to 0022

Suggestion

  • SUGGEST defaults to true

Package Management

  • apk permitted for mini with doas

Packages

  • cargo
  • rustfmt

USAGE

Dockerfile

FROM kgrv/rust AS build
Static Compilation
  • compile script is packaged to simplify build process.
    A script to compile static Rust binary.

    USAGE: compile [OPTIONS] [CARGO_BUILD_ARGUMENTS]

    EXAMPLES:
        compile --release
        compile --target-arch arm64 --release

    OPTIONS:
        ARCH comprises of 'amd64' and 'arm64'
             defaults to build platform architecture

        -b, --build-arch ARCH       Build platform architecture
        -t, --target-arch ARCH      Target platform architecture
        -m, --move APP              Move APP binary to /tmp/
        -d, --debug                 Enable debug mode
        --version                   Display version
        --help                      Display usage information

    ENVIRONMENT:
        Set environment variables to corresponding options

        BUILDARCH  [--build-arch]   Build platform architecture
        TARGETARCH [--target-arch]  Target platform architecture
        APP, MOVE  [--move]         Package binary name

    Check out 'README.md' at https://hub.docker.com/r/kgrv/rust
Example

build stage from kgrv/nreq:

FROM kgrv/rust AS build

ARG APP="nreq"
ARG BUILDARCH
ARG TARGETARCH

WORKDIR /tmp
COPY --link Cargo.toml .
COPY --link src/ src/
RUN --mount=type=cache,sharing=private,target=/tmp/target/ \
    compile --features binary --bin "${APP}" --release --debug

Docker CLI

docker run -it kgrv/rust
Start container with bind mount
docker run -it -v $(pwd):/mnt kgrv/rust
Start container with UID / GID

Important

Argument --user is not supported, please use EUID/EGID.

docker run -it -e EUID=$(id -u) -e EGID=$(id -g) kgrv/rust
Start container as ROOT
docker run -it kgrv/rust --BECOME_ROOT
Install packages
doas apk add PACKAGE

Tag summary

Content type

Image

Digest

sha256:8e260d3bd

Size

262.6 MB

Last updated

17 days ago

docker pull kgrv/rust