Sign inSign up

lawliet89/docker-rust

By lawliet89

Updated about 9 years ago

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

Image
0

852

lawliet89/docker-rust repository overview

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]

Tag summary

Content type

Image

Digest

Size

338.7 MB

Last updated

about 9 years ago

docker pull lawliet89/docker-rust