Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!Cargo.lock
!Cargo.toml
!src
31 changes: 21 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
# Build stage
FROM rust:bookworm AS builder
FROM rust:1.95.0-trixie@sha256:f49565f188ee00bc2a18dd418183f2c5f23ef7d6e691890517ed341a598f67c3 AS builder

WORKDIR /usr/src/git-mirror

# Copy only necessary files for build
COPY Cargo.toml Cargo.lock .
COPY src src
# Cache dependencies
RUN \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=src/lib.rs,target=src/lib.rs \
--mount=type=bind,source=src/main.rs,target=src/main.rs \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo fetch --locked

COPY . .

# Build application
RUN cargo install --path .
RUN \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo install --path . --locked

# Runtime stage
FROM debian:bookworm-slim
FROM debian:13.5-slim@sha256:b6e2a152f22a40ff69d92cb397223c906017e1391a73c952b588e51af8883bf8

# Install dependencies and clean up in single RUN
RUN apt-get update && \
apt-get install -y --no-install-recommends git-core git-lfs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN set -eux ; \
apt-get update -qq ; \
apt-get install -qqy --no-install-recommends git-core git-lfs ; \
apt-get clean ; \
rm -rf /var/lib/apt/lists/* ;

WORKDIR /usr/local/bin
COPY --from=builder /usr/local/cargo/bin/git-mirror .
Loading