Skip to content
Open
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
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Stage 1: Build
FROM rust:1.88-bookworm AS builder
FROM rust:1.90-bookworm AS builder

# Install clippy and rustfmt first to allow the persistent cache to cover them
RUN rustup component add clippy rustfmt

# Install build dependencies
RUN apt-get update && apt-get install -y \
Expand All @@ -17,8 +20,17 @@ COPY . .
## This makes the image large but ensures fast startup in Cloud Run
#RUN wget -c https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle -O /usr/src/sashiko/linux-kernel.bundle

# Build for release
RUN cargo build --release
# Build for release with persistent cache
# Note: some Docker versions could run into bugs when a later stage accesses a
# cached directory from previous stages, so copy the binaries into a separate
# directory first.
RUN --mount=type=cache,target=/usr/src/sashiko/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --release && \
mkdir -p /app && \
cd /usr/src/sashiko/target/release/ && \
cp -a sashiko review sashiko-cli /app

# Stage 2: Runtime
FROM debian:bookworm-slim
Expand All @@ -36,9 +48,7 @@ RUN apt-get update && apt-get install -y \
WORKDIR /app

# Copy binaries from builder
COPY --from=builder /usr/src/sashiko/target/release/sashiko /usr/local/bin/sashiko
COPY --from=builder /usr/src/sashiko/target/release/review /usr/local/bin/review
COPY --from=builder /usr/src/sashiko/target/release/sashiko-cli /usr/local/bin/sashiko-cli
COPY --from=builder /app /usr/local/bin

## Copy the pre-downloaded kernel bundle
#COPY --from=builder /usr/src/sashiko/linux-kernel.bundle /opt/linux-kernel.bundle
Expand Down