# Pre-built image for Google Gemini CLI agent evaluation.
#
# Build:
#   docker build -f evalscope/agent/external/dockerfiles/Dockerfile.gemini-cli \
#                -t evalscope-gemini-cli:latest .
#
# Usage:
#   When running EvalScope with framework='gemini-cli' and pointing the
#   environment at this image, ``setup()`` detects the pre-installed
#   ``gemini`` binary and skips the npm install step entirely.
#
# If you do NOT use this image, the runner's ``auto_install=True``
# (default) will install Node.js + @google/gemini-cli 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 gemini-cli at runtime.
RUN apt-get update && apt-get install -y --no-install-recommends \
        git curl ca-certificates && \
    rm -rf /var/lib/apt/lists/*

# Install @google/gemini-cli globally.
# Pinned to 0.43.0: versions 0.44.x+ have a regression where custom
# GOOGLE_GEMINI_BASE_URL + non-standard API keys fail with "Invalid auth
# method selected" (github.com/google-gemini/gemini-cli/issues/27550).
# Remove the version pin once the upstream fix is released.
RUN npm install -g --no-fund --no-audit @google/gemini-cli@0.43.0 && \
    gemini --version

# Default working directory for the agent.
WORKDIR /workspace
