Skip to content

Commit c28f834

Browse files
fix: replace --mount=type=cache with dependency layer caching in Dockerfiles
--mount=type=cache does not persist across GitHub Actions runners, causing full recompilation on every release build. Reintroduce the "empty main" trick for reliable Docker layer caching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a005a14 commit c28f834

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Auto-tag workflow: CI automatically creates a git tag when `Cargo.toml` version changes on main, triggering the release workflow.
1212
- `/release` skill for Claude Code: guided release preparation with version determination, confirmation, and PR creation.
1313

14+
### Fixed
15+
- Replaced Dockerfile `--mount=type=cache` with dependency layer caching ("empty main" trick) for reliable Docker build caching in GitHub Actions, where `--mount=type=cache` does not persist across runners.
16+
1417
## [1.2.0] - 2026-03-11
1518

1619
### Added

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ ARG VERSION=dev
33
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static perl
44
WORKDIR /src
55
COPY Cargo.toml Cargo.lock ./
6-
COPY . .
7-
RUN --mount=type=cache,target=/usr/local/cargo/registry \
8-
--mount=type=cache,target=/src/target \
6+
RUN mkdir src && echo 'fn main() {}' > src/main.rs && \
97
cargo build --release && \
10-
cp target/release/initium /initium
8+
rm -rf src target/release/deps/initium* target/release/initium*
9+
COPY . .
10+
RUN cargo build --release
1111
FROM scratch
1212
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
13-
COPY --from=builder /initium /initium
13+
COPY --from=builder /src/target/release/initium /initium
1414
USER 65534:65534
1515
ENTRYPOINT ["/initium"]

jyq.Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ ARG VERSION=dev
33
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static perl
44
WORKDIR /src
55
COPY Cargo.toml Cargo.lock ./
6-
COPY . .
7-
RUN --mount=type=cache,target=/usr/local/cargo/registry \
8-
--mount=type=cache,target=/src/target \
6+
RUN mkdir src && echo 'fn main() {}' > src/main.rs && \
97
cargo build --release && \
10-
cp target/release/initium /initium
8+
rm -rf src target/release/deps/initium* target/release/initium*
9+
COPY . .
10+
RUN cargo build --release
1111
FROM alpine:3.21
1212
RUN apk add --no-cache jq yq ca-certificates \
1313
&& rm -rf /var/cache/apk/*
14-
COPY --from=builder /initium /initium
14+
COPY --from=builder /src/target/release/initium /initium
1515
USER 65534:65534
1616
ENTRYPOINT ["/initium"]

0 commit comments

Comments
 (0)