Optimize backend test container to save space
Some checks failed
Podman Rootless Demo / test-backend (push) Failing after 8m40s
Podman Rootless Demo / test-frontend (push) Has been skipped
Podman Rootless Demo / build-backend (push) Has been skipped
Podman Rootless Demo / build-frontend (push) Has been skipped
Podman Rootless Demo / deploy-prod (push) Has been skipped
Some checks failed
Podman Rootless Demo / test-backend (push) Failing after 8m40s
Podman Rootless Demo / test-frontend (push) Has been skipped
Podman Rootless Demo / build-backend (push) Has been skipped
Podman Rootless Demo / build-frontend (push) Has been skipped
Podman Rootless Demo / deploy-prod (push) Has been skipped
This commit is contained in:
parent
870dcd3b1c
commit
9506b4b09c
1 changed files with 11 additions and 2 deletions
|
|
@ -21,12 +21,21 @@ RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
FROM base AS test-build
|
FROM base AS test-build
|
||||||
COPY --from=deps /usr/local/cargo /usr/local/cargo
|
COPY --from=deps /usr/local/cargo /usr/local/cargo
|
||||||
COPY --from=deps /usr/local/rustup /usr/local/rustup
|
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 . .
|
COPY . .
|
||||||
|
# Clean up incremental compilation artifacts before test build
|
||||||
|
RUN rm -rf /app/target/debug/incremental
|
||||||
RUN cargo test --workspace --locked --no-run
|
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
|
# Runner: minimal runtime for test execution
|
||||||
FROM base AS runner
|
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
|
WORKDIR /app
|
||||||
CMD ["cargo", "test", "--workspace", "--locked", "--", "--test-threads=1"]
|
CMD ["cargo", "test", "--workspace", "--locked", "--", "--test-threads=1"]
|
||||||
Loading…
Add table
Reference in a new issue