FROM python:3.11-slim

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

WORKDIR /app

# Clone a vulnerable version of urllib3
RUN git clone -o origin --single-branch https://github.com/urllib3/urllib3.git /app && \
    cd /app && \
    git checkout -q tags/1.24.1 -b bench && \
    git remote remove origin && \
    git tag -d $(git tag -l) || true && \
    git reflog expire --expire=now --all && \
    git gc --prune=now --aggressive

RUN pip install --upgrade pip==24.2 && pip install pytest

# Install urllib3 from source
RUN pip install .
