From 9506b4b09c96c868db92e9511f5cacb73f2a6180 Mon Sep 17 00:00:00 2001 From: continuist Date: Sun, 21 Sep 2025 12:09:52 -0400 Subject: [PATCH] Optimize backend test container to save space --- backend/Dockerfile.test-rust | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile.test-rust b/backend/Dockerfile.test-rust index b01ecc7..f17da91 100644 --- a/backend/Dockerfile.test-rust +++ b/backend/Dockerfile.test-rust @@ -21,12 +21,21 @@ RUN cargo chef cook --release --recipe-path recipe.json FROM base AS test-build COPY --from=deps /usr/local/cargo /usr/local/cargo COPY --from=deps /usr/local/rustup /usr/local/rustup -COPY --from=deps /app/target /app/target +# Copy only release artifacts to save space +COPY --from=deps /app/target/release /app/target/release COPY . . +# Clean up incremental compilation artifacts before test build +RUN rm -rf /app/target/debug/incremental RUN cargo test --workspace --locked --no-run +# Clean up after test build to save space +RUN rm -rf /app/target/debug/incremental /app/target/debug/build /app/target/debug/deps # Runner: minimal runtime for test execution FROM base AS runner -COPY --from=test-build /app /app +# Copy only necessary artifacts for test execution +COPY --from=test-build /app/target /app/target +COPY --from=test-build /app/Cargo.toml /app/Cargo.toml +COPY --from=test-build /app/Cargo.lock /app/Cargo.lock +COPY --from=test-build /app/crates /app/crates WORKDIR /app CMD ["cargo", "test", "--workspace", "--locked", "--", "--test-threads=1"] \ No newline at end of file