# Adapted from Aider-AI/aider benchmark/Dockerfile (Java dropped: Gradle needs network at test time).
# Runs with --network none; the only outside channel is the LLM socket bridged by socat on 127.0.0.1:4000.
FROM docker.io/library/buildpack-deps:noble
RUN apt-get update && apt-get install -y cmake libboost-all-dev libtbb-dev python3 python3-venv python3-pip \
    python3-pytest socat tmux ripgrep jq && rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://go.dev/dl/go1.23.4.linux-amd64.tar.gz -o /tmp/go.tgz && tar -C /usr/local -xzf /tmp/go.tgz && rm /tmp/go.tgz
ENV PATH="/usr/local/go/bin:/root/.cargo/bin:${PATH}" GOFLAGS=-mod=mod GOTOOLCHAIN=local GOPROXY=off
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /npm-install && cd /npm-install && npm init -y >/dev/null && npm install jest @babel/core@7.25.2 \
    @exercism/babel-preset-javascript@0.2.1 @exercism/eslint-config-javascript@0.6.0 @types/jest@29.5.12 \
    @types/node@20.12.12 babel-jest@29.6.4 core-js@3.37.1 eslint@8.49.0
# Pre-fetch the three crates some Rust exercises use, so cargo works offline.
RUN cargo new /tmp/warm && cd /tmp/warm && printf 'anyhow = "1.0"\nrand = "0.8"\ntime = "0.3"\n' >> Cargo.toml && cargo build && rm -rf /tmp/warm
ENV CARGO_NET_OFFLINE=true
# Harnesses (public, unmodified) in their own venv. Versions pinned after the fact to what the study's build resolved
# (image/build.log); the OpenHands copy here is unused, the runs used /opt/oh from Dockerfile.v2.
RUN python3 -m venv /opt/hv && /opt/hv/bin/pip install --no-cache-dir -U pip \
    && /opt/hv/bin/pip install --no-cache-dir aider-chat==0.86.2 mini-swe-agent==2.4.6 litellm==1.81.10 openhands-sdk==1.14.0 openhands-tools==1.50.1
COPY npm-test.sh cpp-test.sh /usr/local/bin/
WORKDIR /work
