perf(ci): cache cargo registry and target dir across image builds
All checks were successful
build-and-release / build (employees) (push) Successful in 5m50s
build-and-release / build (developers) (push) Successful in 6m1s
build-and-release / build (catering-services) (push) Successful in 6m29s
build-and-release / build (cron) (push) Successful in 6m45s
build-and-release / build (companies) (push) Successful in 7m13s
build-and-release / build (customers) (push) Successful in 7m27s
build-and-release / build (fitness-trainers) (push) Successful in 1m57s
build-and-release / build (gateway) (push) Successful in 1m52s
build-and-release / build (jobs) (push) Successful in 1m9s
build-and-release / build (graphic-designers) (push) Successful in 2m24s
build-and-release / build (job-seekers) (push) Successful in 2m32s
build-and-release / build (makeup-artists) (push) Successful in 2m0s
build-and-release / build (leads) (push) Successful in 2m39s
build-and-release / build (tutors) (push) Successful in 1m40s
build-and-release / build (ugc-content-creators) (push) Successful in 1m38s
build-and-release / build (social-media-managers) (push) Successful in 2m39s
build-and-release / build (payments) (push) Successful in 3m45s
build-and-release / build (video-editors) (push) Successful in 1m41s
build-and-release / build (photographers) (push) Successful in 4m38s
build-and-release / build (users) (push) Successful in 7m27s
All checks were successful
build-and-release / build (employees) (push) Successful in 5m50s
build-and-release / build (developers) (push) Successful in 6m1s
build-and-release / build (catering-services) (push) Successful in 6m29s
build-and-release / build (cron) (push) Successful in 6m45s
build-and-release / build (companies) (push) Successful in 7m13s
build-and-release / build (customers) (push) Successful in 7m27s
build-and-release / build (fitness-trainers) (push) Successful in 1m57s
build-and-release / build (gateway) (push) Successful in 1m52s
build-and-release / build (jobs) (push) Successful in 1m9s
build-and-release / build (graphic-designers) (push) Successful in 2m24s
build-and-release / build (job-seekers) (push) Successful in 2m32s
build-and-release / build (makeup-artists) (push) Successful in 2m0s
build-and-release / build (leads) (push) Successful in 2m39s
build-and-release / build (tutors) (push) Successful in 1m40s
build-and-release / build (ugc-content-creators) (push) Successful in 1m38s
build-and-release / build (social-media-managers) (push) Successful in 2m39s
build-and-release / build (payments) (push) Successful in 3m45s
build-and-release / build (video-editors) (push) Successful in 1m41s
build-and-release / build (photographers) (push) Successful in 4m38s
build-and-release / build (users) (push) Successful in 7m27s
Dockerfile.simple had no build caching at all - every push recompiled the full dependency tree from scratch for every service, in release mode, targeting musl with static OpenSSL (the slowest possible combination). BuildKit cache mounts for /app/target and the cargo registry/git caches persist across builds on the same runner node and are shared across all 20 services, since they overlap heavily on workspace dependencies. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
f5201965d8
commit
3e2f3dd85d
1 changed files with 9 additions and 3 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
# Simple fast Dockerfile - no fancy caching, just builds fast
|
# syntax=docker/dockerfile:1.7
|
||||||
# Uses local cargo cache between builds
|
|
||||||
|
|
||||||
ARG SERVICE_NAME
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
|
|
@ -48,7 +47,14 @@ RUN svc=$(echo "${SERVICE_NAME}" | tr '-' '_') && \
|
||||||
ENV RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
ENV RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
||||||
ENV OPENSSL_STATIC=1
|
ENV OPENSSL_STATIC=1
|
||||||
ENV OPENSSL_DIR=/usr
|
ENV OPENSSL_DIR=/usr
|
||||||
RUN cargo build --release \
|
# Cache mounts persist across builds on the same runner node's buildkit
|
||||||
|
# daemon (keyed by target path, shared across all 20 services' builds since
|
||||||
|
# they overlap heavily on the same workspace deps) - avoids recompiling the
|
||||||
|
# full dependency tree from scratch on every push.
|
||||||
|
RUN --mount=type=cache,target=/app/target,sharing=locked \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/git \
|
||||||
|
cargo build --release \
|
||||||
--bin $(cat /tmp/service_bin) \
|
--bin $(cat /tmp/service_bin) \
|
||||||
--target x86_64-unknown-linux-musl && \
|
--target x86_64-unknown-linux-musl && \
|
||||||
cp /app/target/x86_64-unknown-linux-musl/release/$(cat /tmp/service_bin) /app/service
|
cp /app/target/x86_64-unknown-linux-musl/release/$(cat /tmp/service_bin) /app/service
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue