FROM lukemathwalker/cargo-chef:latest-rust-slim-bookworm AS planner WORKDIR /app COPY . . RUN cargo chef prepare --recipe-path recipe.json FROM lukemathwalker/cargo-chef:latest AS cacher WORKDIR /app COPY --from=planner /app/recipe.json recipe.json # Build and cache only the dependencies RUN cargo chef cook --release --recipe-path recipe.json FROM rust:latest AS builder WORKDIR /app RUN apt-get update && apt-get install -y \ pkg-config \ libssl-dev COPY --from=cacher /app/target target COPY --from=cacher /usr/local/cargo /usr/local/cargo COPY . . COPY .env ./.env RUN cargo build --release --bin server-mark2-dev FROM debian:bookworm-slim AS runtime WORKDIR /app COPY --from=builder /app/target/release/server-mark2-dev /usr/local/bin/server-mark2-dev COPY --from=builder /app/.env /usr/local/bin/.env CMD [ "server-mark2-dev" ]