# syntax=docker/dockerfile:1
FROM rust:1.97.1-bookworm@sha256:0e2bcaef56d041a486784e54104a81aebe0da44bd03019bd70bc0401e42e4a97 AS builder

RUN apt-get update && apt-get install -y build-essential python3-dev

WORKDIR /tests
COPY . .
RUN --mount=type=cache,id=distsys-course-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
    --mount=type=cache,id=distsys-course-cargo-target-rust-1-97-1,target=/tests/target,sharing=locked \
    cargo install --locked --path . --root /opt/course

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y python3-dev && rm -rf /var/lib/apt/lists/*

COPY --from=builder /opt/course/bin/distsys-ping-pong /usr/local/bin/distsys-ping-pong

WORKDIR /solution
ENTRYPOINT ["distsys-ping-pong"]
