# syntax=docker/dockerfile:1
FROM python:3.12-alpine

COPY tests/requirements.txt .
RUN --mount=type=cache,id=distsys-course-pip,target=/root/.cache/pip,sharing=locked \
    pip install -r requirements.txt

ARG GRPCURL_VERSION=1.9.3
ARG GRPCURL_SHA256=a926b62a85787ccf73ef8736b3ae554f1242e39d92bb8767a79d6dd23b11d1d5
RUN apk add --no-cache curl tini \
    && curl --fail --silent --show-error --location \
        "https://github.com/fullstorydev/grpcurl/releases/download/v${GRPCURL_VERSION}/grpcurl_${GRPCURL_VERSION}_linux_x86_64.tar.gz" \
        --output /tmp/grpcurl.tar.gz \
    && echo "${GRPCURL_SHA256}  /tmp/grpcurl.tar.gz" | sha256sum -c \
    && tar -xzf /tmp/grpcurl.tar.gz -C /usr/local/bin \
    && rm -f /tmp/grpcurl.tar.gz

COPY solution/proto/ solution/proto/
COPY tests/*.py tests/

ENTRYPOINT ["/sbin/tini", "--", "python3", "-u", "tests/main.py"]
