# Pre-built image for OpenCode agent evaluation.
#
# Build:
#   docker build -f evalscope/agent/external/dockerfiles/Dockerfile.opencode \
#                -t evalscope-opencode:latest .
#
# Usage:
#   When running EvalScope with framework='opencode' and pointing the
#   environment at this image, ``setup()`` detects the pre-installed
#   ``opencode`` binary and skips the Node.js/npm install step entirely.
#
# If you do NOT use this image, the runner's ``auto_install=True``
# (default) will install Node.js + opencode-ai at runtime — functional
# but adds ~30-60s on first invocation.

FROM node:22-slim

# Use Chinese mirrors for faster builds in mainland China.
# apt: Aliyun Debian mirror; npm: npmmirror.
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
    sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
RUN npm config set registry https://registry.npmmirror.com

# System utilities required by OpenCode at runtime.
RUN apt-get update && apt-get install -y --no-install-recommends \
        git curl ca-certificates && \
    rm -rf /var/lib/apt/lists/*

# Install opencode-ai globally.
RUN npm install -g --no-fund --no-audit opencode-ai && \
    opencode --version

# Default working directory for the agent.
WORKDIR /workspace
