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
41 lines
No EOL
1.7 KiB
Text
41 lines
No EOL
1.7 KiB
Text
# Base stage with consistent working directory
|
|
FROM docker.io/rust:1.89-slim AS base
|
|
WORKDIR /app
|
|
|
|
# Planner: produce recipe.json
|
|
FROM base AS planner
|
|
RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
RUN cargo install --locked cargo-chef
|
|
COPY . .
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
# Deps: compile only external crates
|
|
FROM base AS deps
|
|
RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
RUN cargo install --locked cargo-chef
|
|
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
|
COPY --from=planner /app/recipe.json recipe.json
|
|
RUN cargo chef cook --release --recipe-path recipe.json
|
|
|
|
# Test-build: compile workspace with pre-built dependencies
|
|
FROM base AS test-build
|
|
COPY --from=deps /usr/local/cargo /usr/local/cargo
|
|
COPY --from=deps /usr/local/rustup /usr/local/rustup
|
|
# 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 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"] |