@@ -15,6 +15,9 @@ WORKDIR /tmp
1515RUN apt-get update; apt-get install -y curl sqlite3; apt-get autoclean
1616RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
1717RUN cargo binstall --no-confirm cargo-nextest
18+ # Database initialization: Tests at runtime require a pre-initialized SQLite3 database
19+ # to test against a valid (not corrupted) schema. The VACUUM command optimizes the
20+ # database file layout. This image layer is inherited by test_debug and test stages.
1821
1922COPY ./share/ /app/share/torrust
2023RUN mkdir -p /app/share/torrust/default/database/; \
@@ -38,13 +41,19 @@ FROM chef AS dependencies_debug
3841WORKDIR /build/src
3942COPY --from=recipe /build/recipe.json /build/recipe.json
4043RUN cargo chef cook --tests --benches --examples --workspace --all-targets --all-features --recipe-path /build/recipe.json
44+ # Pre-link warm-up: Create and discard a nextest archive to warm up the linker
45+ # before final compilation. This improves incremental build cache efficiency
46+ # by pre-faulting the linker phases, avoiding redundant linking work in later stages.
4147RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/temp.tar.zst ; rm -f /build/temp.tar.zst
4248
4349# # Cook (release)
4450FROM chef AS dependencies
4551WORKDIR /build/src
4652COPY --from=recipe /build/recipe.json /build/recipe.json
4753RUN cargo chef cook --tests --benches --examples --workspace --all-targets --all-features --recipe-path /build/recipe.json --release
54+ # Pre-link warm-up: Create and discard a nextest archive to warm up the linker
55+ # before final compilation. This improves incremental build cache efficiency
56+ # by pre-faulting the linker phases, avoiding redundant linking work in later stages.
4857RUN cargo nextest archive --tests --benches --examples --workspace --all-targets --all-features --archive-file /build/temp.tar.zst --release ; rm -f /build/temp.tar.zst
4958
5059
0 commit comments