HUB
Sign inSign up
rust logo

gustavofreze/rust

By gustavofreze

•Updated 3 days ago

Hardened, reproducible Rust base images: runtime, development, builder and cli. Non-root.

Image
Languages & frameworks
Developer tools
0

743

gustavofreze/rust repository overview

⁠gustavofreze/rust

Hardened, reproducible Rust base images. One Dockerfile per upstream version ships four targets: the production runtime for a static binary, its development variant, the builder toolchain for a project's production build, and a cli tooling image a project Makefile invokes.

⁠Quick reference

⁠Supported tags

TagAliasPurpose
1.100-runtime-1.0.11.100-runtimeProduction base for a static binary. No toolchain, no shell kit.
1.100-development-1.0.11.100-developmentLocal development and Dev Containers: runtime plus the toolchain.
1.100-builder-1.0.11.100-builderCargo and the musl toolchain for the builder stage of an image.
1.100-cli-1.0.11.100-cliMakefile tooling: Cargo, Clippy, rustfmt, git, bash, curl.

Every tag is <upstream-minor>-<target>-<version>. There is no bare tag and latest is forbidden.

  • Versioned tag. Immutable and reproducible. It moves only when you bump it, so take it for anything that ships.
  • Alias. Tracks the latest rebuild of its target, the monthly security rebuild included, and never crosses an upstream minor: 1.100-runtime stays on 1.100. It moves only when the client re-pulls, which suits cli and local development.

All four are built from one multi-target Dockerfile⁠, pinned to rust:1.100.0-alpine3.24 for the toolchain and to alpine:3.24.4 for the runtime.

⁠Image variants

Image family targets

TargetRuns asOn top of the base
runtimeapp (uid 1000)Nothing. A pinned Alpine in a single layer, around 13 MB.
developmentapp (uid 1000)runtime plus rustc, Cargo, Clippy, rustfmt, rust-src, gcc, bash, git, curl.
builderapp (uid 1000)The upstream toolchain: rustc and Cargo targeting musl, gcc, musl-dev.
clirootbuilder plus Clippy, rustfmt, bash, curl, git.
  • runtime is not built on the Rust image. A release binary targeting musl links statically, so it needs no interpreter, no standard library on disk, and no compiler runtime.
  • development is built FROM runtime. It runs on a developer machine and is never deployed.
  • builder keeps the whole toolchain on purpose. It is the stage a project compiles its binary in, and the multi-stage application build discards it.
  • cli stays root so it can write into a bind mount owned by the caller.
  • No target ships a HEALTHCHECK or exposes a port. These are language bases, not services, so the application that inherits the runtime declares the health check for the process it actually runs.

⁠What it provides

Every image provides, and no consuming Dockerfile re-declares:

  • A non-root runtime. The app user (uid 1000), whose home is the /app working directory it owns.
  • The Alpine certificate bundle at /etc/ssl/certs/ca-certificates.crt, so a binary that verifies TLS against the system store works unchanged. A project that trusts a private authority adds the ca-certificates package itself.
  • A current zlib, upgraded to what the Alpine index serves at build time instead of aging in place between base releases.
  • RUST_BACKTRACE=1 in runtime and development, so a panic prints its backtrace instead of a hint to set the variable.
  • No toolchain in production. The runtime carries no Cargo, no rustc, no linker, no git, no bash, and no curl, and the smoke suite asserts each absence.
  • Static binaries with no flag. A release build in the builder links statically against musl, and the smoke suite proves it by running one in the runtime.
  • A writable CARGO_HOME at the upstream /usr/local/cargo wherever the toolchain ships, so the app user fetches crates into it with no extra configuration.
  • A Dev Container ready development. It carries rust-src, so an IDE resolves the standard library, and the packages a JetBrains backend needs inside the container: gcompat, the X11 rendering libraries, curl, unzip, and procps.

⁠How to use this image

⁠As a base image

A project consumes the base in two thin files and adds only its own dependencies, code, and tuning:

# syntax=docker/dockerfile:1
FROM gustavofreze/rust:1.100-development-1.0.1
COPY ./ /app
# syntax=docker/dockerfile:1
FROM gustavofreze/rust:1.100-builder-1.0.1 AS builder
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked
COPY ./ ./
RUN cargo build --release --locked --offline

FROM gustavofreze/rust:1.100-runtime-1.0.1
COPY --from=builder --chown=app:app /app/target/release/your-application /app/your-application
CMD ["/app/your-application"]

cargo fetch reads only the manifest and the lock file, so the dependency download is its own layer and a code change does not repeat it. A crate that links a C library needs that library's development package in the builder stage and its shared object in the runtime stage, both added by the project.

⁠As a Dev Container

The development target is the image a Dev Container runs, with the project mounted as its workspace:

{
    "image": "gustavofreze/rust:1.100-development-1.0.1",
    "remoteUser": "app"
}
⁠As a tooling image

The cli image is invoked directly and never appears in a Dockerfile.

To lint the code, run:

docker run --rm -v "$(pwd)":/app gustavofreze/rust:1.100-cli-1.0.1 cargo clippy --all-targets -- -D warnings

To check the formatting, run:

docker run --rm -v "$(pwd)":/app gustavofreze/rust:1.100-cli-1.0.1 cargo fmt --check

The rules that hold across every family live in the usage contract⁠.

⁠Verification

No tag is published before it passes the full gate⁠, on a native linux/amd64 runner and a native linux/arm64 one:

StageToolWhat it checks
Linthadolint, ShellCheckEvery Dockerfile and every RUN body.
ScanTrivy and GrypeFixable HIGH and CRITICAL vulnerabilities.
AuditDockleThe CIS Docker Benchmark.
EfficiencydiveWasted layer space.
Smokethrowaway containersThe runtime contract, in throwaway containers.

The smoke suite asserts the non-root user, the pinned toolchain version, linters only where they belong, the absence of a toolchain in the production surface, and a release binary compiled in the builder running in the runtime.

This family carries no accepted risk, so it publishes no OpenVEX⁠ analysis and no scanner exemption of any kind. Every scan in the gate runs bare, and what it reports is what the images contain.

To scan a tag yourself, run:

trivy image gustavofreze/rust:1.100-runtime-1.0.1

⁠License

MIT⁠

Tag summary

Content type

Image

Digest

sha256:497b649ca…

Size

365.2 MB

Last updated

3 days ago

docker pull gustavofreze/rust:1.100-development