From 31025c245cd9a629e305c7d35d7fe63d47da2e88 Mon Sep 17 00:00:00 2001 From: andrea Date: Thu, 8 May 2025 08:19:45 +0000 Subject: [PATCH] feat(ci): speed up builds by caching dependencies --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 948b1a0..451ebac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld WORKDIR /app +# this optimizes build time by putting the dependencies in a seperate docker layer, speeding up future builds +COPY Cargo.toml Cargo.lock ./ +RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo fetch + COPY . . RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl