forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (30 loc) · 1.1 KB
/
Copy pathDockerfile
File metadata and controls
38 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# syntax=docker/dockerfile:latest
# Test 1: sccache with BuildKit cache mount
# Purpose: Verify sccache works inside Docker with RUN --mount=type=cache
# and that the cache persists across builds.
FROM docker.io/library/rust:trixie AS experiment
# Install sccache
RUN cargo install sccache --locked
# Config
ENV RUSTC_WRAPPER=sccache
ENV SCCACHE_DIR=/sccache
ENV CARGO_INCREMENTAL=0
ENV CARGO_TERM_COLOR=always
WORKDIR /app
# Copy source
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# Cold build: sccache cache should be empty
RUN --mount=type=cache,target=/sccache \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
cargo build --release 2>&1 && \
echo "=== COLD BUILD COMPLETE ===" && \
sccache --show-stats
# Warm build (same layer, same RUN): sccache should have cached external deps
RUN --mount=type=cache,target=/sccache \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
cargo build --release 2>&1 && \
echo "=== WARM BUILD COMPLETE ===" && \
sccache --show-stats