sharenet/backend/Dockerfile.test-rust
continuist 2ec2d0c68b
Some checks failed
Podman Rootless Demo / test-backend (push) Failing after 39s
Install postgres client in backend test container from GitHub to avoid seccomp issues
2025-09-19 18:58:06 -04:00

32 lines
No EOL
1.4 KiB
Text

# planner: produce recipe.json
FROM docker.io/rust:1.89-slim AS planner
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libssl-dev ca-certificates postgresql-client curl && 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 docker.io/rust:1.89-slim AS deps
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libssl-dev ca-certificates postgresql-client curl && 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
# builder: compile local workspace crates using cached deps
FROM docker.io/rust:1.89-slim AS builder
WORKDIR /app
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 . .
RUN cargo build --release --locked
# runtime: minimal test environment with PostgreSQL client
FROM docker.io/rust:1.89-slim AS runtime
# Install PostgreSQL client using static binary to avoid seccomp issues
RUN curl -fsSL https://github.com/wrouesnel/postgresql-client/releases/download/v15.7.0/pg15.7.0-linux-amd64.tar.gz | tar -xz -C /usr/local/bin --strip-components=1
WORKDIR /workspace/backend
CMD ["sleep", "infinity"]