FROM python:3.14-bookworm

LABEL Name=Schemathesis

WORKDIR /app

RUN groupadd --gid 1000 --system schemathesis && \
    useradd --uid 1000 --system schemathesis -g schemathesis -s /sbin/nologin

COPY --chown=1000:1000 pyproject.toml README.md src ./

RUN apt-get update \
    && apt-get install --no-install-recommends -y build-essential libffi-dev libssl-dev curl \
    && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
    && pip install --upgrade pip && PATH=$HOME/.cargo/bin:$PATH pip install --no-cache-dir ./ \
    && apt remove -y build-essential libffi-dev libssl-dev curl \
    && PATH=$HOME/.cargo/bin:$PATH rustup self uninstall -y \
    && apt -y autoremove \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# Needed for the `.hypothesis` directory
RUN chown -R 1000:1000 /app

USER schemathesis

ENV SCHEMATHESIS_DOCKER_IMAGE=3.14-bookworm

ENTRYPOINT ["schemathesis"]
