Public Repository

Last pushed: 4 months ago
Short Description
A Docker image that allows building of Rust applications for Linux machines.
Full Description

docker-rust

A Docker image that allows building of Rust applications for Linux machines.

The image comes out of the box with support for x86_64-unknown-linux-musl and x86_64-unknown-linux-gnu
target triple. The default target is x86_64-unknown-linux-gnu.

This is published on Dockerhub.

Tags

Usage

Multi-stage builds are recommended
so that the final image will be as small and compact as possible. This is demonstrated in the examples below.

Target x86_64-unknown-linux-gnu

FROM lawliet89/docker-rust:1.19.0 as builder

WORKDIR /app/src
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked -v

COPY ./ ./
RUN cargo build --release -v --frozen

# Runtime Image

FROM alpine:3.5
WORKDIR /app
COPY --from=builder /app/src/target/release/your_application_name_here .
CMD [/app/your_application_name_here]

Target x86_64-unknown-linux-musl

FROM lawliet89/docker-rust:1.19.0 as builder

ARG ARCHITECTURE=x86_64-unknown-linux-musl
WORKDIR /app/src
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch --locked -v

COPY ./ ./
RUN cargo build --release --target "${ARCHITECTURE}" -v --frozen

# Runtime Image

FROM alpine:3.5
ARG ARCHITECTURE=x86_64-unknown-linux-musl
WORKDIR /app
COPY --from=builder /app/src/target/${ARCHITECTURE}/release/your_application_name_here .
CMD [/app/your_application_name_here]
Docker Pull Command
Owner
lawliet89