From 20196c23a8a77dd2bdff6f82e5a0b05e26e330e2 Mon Sep 17 00:00:00 2001 From: limiteinductive Date: Sun, 29 Mar 2026 19:25:58 +0200 Subject: [PATCH] optimize: Dockerfile with Rust dependency caching Co-Authored-By: Claude Opus 4.6 (1M context) --- infra/colony/Dockerfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/infra/colony/Dockerfile b/infra/colony/Dockerfile index 717848f..8a9ee9b 100644 --- a/infra/colony/Dockerfile +++ b/infra/colony/Dockerfile @@ -6,11 +6,22 @@ RUN npm ci COPY ui/colony/ . RUN npm run build -# Stage 2: Build backend +# Stage 2: Build backend (with dependency caching) FROM rust:1.86-slim AS backend RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/* WORKDIR /app + +# Cache dependency build: copy manifests first, create stub sources, build deps COPY Cargo.toml Cargo.lock ./ +COPY crates/colony-types/Cargo.toml crates/colony-types/Cargo.toml +COPY crates/colony/Cargo.toml crates/colony/Cargo.toml +RUN mkdir -p crates/colony-types/src crates/colony/src \ + && echo "fn main() {}" > crates/colony/src/main.rs \ + && echo "" > crates/colony-types/src/lib.rs \ + && cargo build --release -p colony 2>/dev/null || true \ + && rm -rf crates/ + +# Now copy real source and build (deps already cached) COPY crates/ crates/ RUN cargo build --release -p colony