FROM python:3.12-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
    git build-essential libgl1 libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/roboflow/inference.git /workspace/inference
WORKDIR /workspace/inference
RUN git fetch --all --tags

# Add commits from deleted branches (bundled from local clone)
COPY missing_commits.bundle /tmp/missing_commits.bundle
RUN git fetch /tmp/missing_commits.bundle "+refs/*:refs/remotes/bundle/*" && \
    rm /tmp/missing_commits.bundle

COPY requirements_core.txt /tmp/requirements_core.txt
RUN pip install --no-cache-dir -r /tmp/requirements_core.txt
RUN pip install --no-cache-dir -e . 2>/dev/null || true
RUN pip install --no-cache-dir codeflash==0.20.5 dill

RUN git config --global user.email "eval@codeflash.ai" && \
    git config --global user.name "Codeflash Evaluator"

ENV CODEFLASH_API_KEY=cf-7aZHMxbhzi2rgg13HF7mJWEX93d-pdKqI1N2lKfjuvrybyX7AsJEx5lcKsy6vox1

WORKDIR /workspace/inference
