# ── Stage 1: build ────────────────────────────────────────────────────────────
FROM rust:1-slim AS builder
WORKDIR /build
# Cache dependency compilation separately from source changes.
# Copy manifests first, build a dummy lib/bin to warm the cache,
# then overwrite with the real source.
COPY Cargo.toml Cargo.lock* ./
COPY Cargo.toml Cargo.toml
# Build for real and run tests.
COPY src src
COPY resources resources
RUN touch src/bin/main.rs src/lib/lib.rs \
&& cargo test \
&& cargo build --release
# ── Stage 2: runtime ──────────────────────────────────────────────────────────
FROM debian:bookworm-slim
COPY --from=builder /build/target/release/rvault /usr/local/bin/rvault
ENTRYPOINT ["rvault"]