···11+# Development only. Not for production use.
22+33+FROM rust:1.96-bookworm AS build
44+55+RUN apt-get update && apt-get install -y --no-install-recommends protobuf-compiler \
66+ && rm -rf /var/lib/apt/lists/*
77+88+WORKDIR /src
99+COPY . .
1010+1111+# Cache mounts on the cargo registry + target dir. The binary is copied out within the same
1212+# RUN because the target cache mount is unmounted afterwards (a later COPY --from could not
1313+# see it).
1414+RUN --mount=type=cache,target=/usr/local/cargo/registry \
1515+ --mount=type=cache,target=/src/target \
1616+ cargo build --release -p gitmirror \
1717+ && cp /src/target/release/gitmirror /usr/local/bin/gitmirror
1818+1919+FROM debian:bookworm-slim
2020+2121+RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates tini \
2222+ && rm -rf /var/lib/apt/lists/*
2323+2424+COPY --from=build /usr/local/bin/gitmirror /usr/local/bin/gitmirror
2525+2626+EXPOSE 9000
2727+2828+ENTRYPOINT ["/usr/bin/tini", "--"]
2929+CMD ["sh", "-c", "if [ -f /usr/local/share/ca-certificates/caddy.crt ]; then update-ca-certificates; fi && exec /usr/local/bin/gitmirror"]