FROM debian:bookworm-slim

# Install Node.js 20, Maven (for arena test projects that require mvn), and
# Eclipse Temurin 21 JRE. The JRE lets devrig (Kotlin/JVM,
# jvmToolchain(21)) run as a stdio MCP under the agent's launcher — used by
# :npx-kt:integrationTest's CliCodexIntegrationTest. Adoptium APT mirrors the
# test-integration ide-base pattern.
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        curl ca-certificates gnupg maven && \
    mkdir -p /etc/apt/keyrings && \
    curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | \
        gpg --dearmor -o /etc/apt/keyrings/adoptium.gpg && \
    echo "deb [signed-by=/etc/apt/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main" \
        > /etc/apt/sources.list.d/adoptium.list && \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | \
        gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" \
        > /etc/apt/sources.list.d/nodesource.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends nodejs temurin-21-jre && \
    rm -rf /var/lib/apt/lists/*

# Install Codex CLI
RUN npm install -g @openai/codex

# Create non-root user
RUN useradd -m -s /bin/bash agent
USER agent
WORKDIR /home/agent

CMD ["sleep", "infinity"]
