git-next/Dockerfile

34 lines
1 KiB
Text
Raw Permalink Normal View History

# Leveraging the pre-built Docker images with
# cargo-chef and the Rust toolchain
FROM git.kemitix.net/kemitix/git-next-builder:latest AS builder
WORKDIR /app
COPY Cargo.toml ./
COPY src src
RUN cargo chef prepare --recipe-path recipe.json
ARG CARGO_PROFILE
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --profile "$CARGO_PROFILE" --recipe-path recipe.json
# Build application
COPY Cargo.toml ./
COPY src src
ARG CARGO_PROFILE
RUN cargo build --profile "$CARGO_PROFILE" --bin git-next
RUN if test "$CARGO_PROFILE" == "release" ; then strip target/release/git-next ; fi
# We do not need the Rust toolchain to run the binary!
FROM docker.io/debian:stable-20240211-slim AS runtime
WORKDIR /app
RUN apt-get update && \
apt-get install --no-install-recommends -y \
libssl3=3.0.11-1~deb12u2 \
ca-certificates=20230311 \
&& \
rm -rf /var/lib/apt/lists/*
USER 1000
ARG CARGO_TARGET
COPY --from=builder /app/target/"$CARGO_TARGET"/git-next /usr/local/bin
ENTRYPOINT [ "/usr/local/bin/git-next" ]