Skip to content

Commit 2974403

Browse files
Merge pull request #2089 from kristof-mattei/pre-cache
fix: pre-cache
2 parents 938f6d6 + 1812a84 commit 2974403

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Dockerfile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt,sharing=locked \
1818
build-essential \
1919
musl-dev
2020

21+
# The following block
22+
# creates an empty app, and we copy in Cargo.toml and Cargo.lock as they represent our dependencies
23+
# This allows us to copy in the source in a different layer which in turn allows us to leverage Docker's layer caching
24+
# That means that if our dependencies don't change rebuilding is much faster
25+
WORKDIR /build
26+
27+
RUN cargo init --name ${APPLICATION_NAME}
28+
29+
COPY ./.cargo ./Cargo.toml ./Cargo.lock ./
30+
31+
# We use `fetch` to pre-download the files to the cache
32+
RUN --mount=type=cache,id=cargo-git,target=/usr/local/cargo/git/db,sharing=locked \
33+
--mount=type=cache,id=cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
34+
cargo fetch
35+
2136
FROM rust-base AS rust-linux-amd64
2237
ARG TARGET=x86_64-unknown-linux-musl
2338

@@ -36,16 +51,6 @@ RUN --mount=type=cache,id=apt-cache-${TARGET},from=rust-base,target=/var/cache/a
3651

3752
RUN rustup target add ${TARGET}
3853

39-
# The following block
40-
# creates an empty app, and we copy in Cargo.toml and Cargo.lock as they represent our dependencies
41-
# This allows us to copy in the source in a different layer which in turn allows us to leverage Docker's layer caching
42-
# That means that if our dependencies don't change rebuilding is much faster
43-
WORKDIR /build
44-
45-
RUN cargo init --name ${APPLICATION_NAME}
46-
47-
COPY ./.cargo ./Cargo.toml ./Cargo.lock ./
48-
4954
RUN --mount=type=cache,target=/build/target/${TARGET},sharing=locked \
5055
--mount=type=cache,id=cargo-git,target=/usr/local/cargo/git/db \
5156
--mount=type=cache,id=cargo-registry,target=/usr/local/cargo/registry \

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "module",
44
"packageManager": "pnpm@10.15.0",
55
"engines": {
6-
"node": "22.19.0",
6+
"node": "24.7.0",
77
"pnpm": "10.15.0"
88
},
99
"scripts": {

0 commit comments

Comments
 (0)