FROM ubuntu:24.04

RUN apt-get update && apt-get install -y --no-install-recommends \
    g++ \
    python3 \
    python3-pip \
    python3-venv \
    python-is-python3 \
    wget \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Install testlib.h for competitive programming checkers (pinned to specific commit)
RUN wget -q -O /usr/include/testlib.h \
    https://raw.githubusercontent.com/MikeMirzayanov/testlib/1e4e8a24c79c6bad3becbdb5a332ffc352b7d5dd/testlib.h

# Install Python packages needed by research problem evaluators
RUN pip3 install --no-cache-dir --break-system-packages \
    numpy==1.26.4 pandas==2.2.2 scipy==1.13.1 sympy==1.13.3 tqdm==4.67.0 \
    pyyaml==6.0.2 matplotlib==3.9.2 configargparse==1.7 filelock==3.16.1 colorama==0.4.6

# CPU-only PyTorch for imagenet_pareto research problems
RUN pip3 install --no-cache-dir --break-system-packages \
    torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu

# FAISS for vdb_pareto research problems
RUN pip3 install --no-cache-dir --break-system-packages \
    faiss-cpu==1.9.0

# Julia runtime (required by PySR for symbolic_regression research problems)
RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.11/julia-1.11.3-linux-x86_64.tar.gz \
    && tar -xzf julia-1.11.3-linux-x86_64.tar.gz -C /usr/local --strip-components=1 \
    && rm julia-1.11.3-linux-x86_64.tar.gz

# PySR for symbolic_regression research problems
RUN pip3 install --no-cache-dir --break-system-packages \
    pysr==1.5.9

# Pre-install PySR's Julia dependencies so they don't need downloading at eval time
RUN python3 -c "import pysr; pysr.install()"

# Create /work/execution_env/solution_env/ for research evaluators.
# evaluate.sh scripts expect solution files at this path.
RUN mkdir -p /work/execution_env/solution_env && chmod 777 /work/execution_env/solution_env

RUN useradd -m agent
USER agent
WORKDIR /home/agent
