move-diff 0.3.1

Render a git diff with extra markers for moved and reformatted code
Documentation
# syntax=docker/dockerfile:1

# ---- builder: compile the move-diff binary ---------------------------------
FROM rust:1-bookworm AS builder
WORKDIR /app

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY Cargo.toml Cargo.lock ./
COPY src ./src

# BuildKit cache mounts persist the crates.io registry and the incremental
# build directory across builds (keyed on this stage), so there's no need for
# a separate dummy-`src` layer to warm the dependency cache. The mounted
# /app/target is removed once the RUN completes, so copy the binary out to a
# plain layer path first.
RUN --mount=type=cache,target=/usr/local/cargo/registry \
    --mount=type=cache,target=/app/target \
    cargo build --release \
 && cp target/release/move-diff /app/move-diff

# ---- runtime -----------------------------------------------------------------
FROM debian:bookworm-slim AS runtime

# Use bash with pipefail so that any RUN with a pipe fails the build if an
# early stage of the pipe fails.
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# git is a genuine runtime dependency: move-diff shells out to `git diff`.
# hadolint ignore=DL3008
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
      ca-certificates \
      git \
 && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/move-diff /usr/local/bin/move-diff

# Run as a non-root user. USER is numeric (rather than "diff") so that
# Kubernetes' runAsNonRoot check can verify it without reading /etc/passwd.
RUN useradd -m -u 1000 -s /bin/bash differ
ENV HOME=/home/differ
USER 1000

# move-diff's directory defaults to `.`; mount the target git repo here,
# e.g. `docker run -v $(pwd):/workspace ...`.
WORKDIR /workspace

ENTRYPOINT ["move-diff"]
CMD ["--help"]