# Development only. Not for production use. FROM rust:1.96-bookworm AS build RUN apt-get update && apt-get install -y --no-install-recommends protobuf-compiler libprotobuf-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /src COPY . . # Cache mounts on the cargo registry + target dir. The binary is copied out within the same # RUN because the target cache mount is unmounted afterwards (a later COPY --from could not # see it). RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/src/target \ cargo build --release -p gitmirror \ && cp /src/target/release/gitmirror /usr/local/bin/gitmirror FROM debian:bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates tini \ && rm -rf /var/lib/apt/lists/* COPY --from=build /usr/local/bin/gitmirror /usr/local/bin/gitmirror EXPOSE 9000 ENTRYPOINT ["/usr/bin/tini", "--"] CMD ["sh", "-c", "if [ -f /usr/local/share/ca-certificates/caddy.crt ]; then update-ca-certificates; fi && exec /usr/local/bin/gitmirror serve"]