# PEP-17/40: the runner image — the agent of one runner (Claude Code, Codex, OpenCode) with
# git and common build tools, and Peppa's shims (peppa-hook, peppa-mcp) that reach Peppa only
# through the agent relay. Same image on Peppa's machine and on runner hosts.
# Build: scripts/runner-image.sh  (tag: $PEPPA_RUNNER_IMAGE, default peppa/runner:latest)
FROM node:22-bookworm-slim

ARG CLAUDE_CODE_VERSION=latest
ARG CODEX_VERSION=latest
ARG OPENSPEC_VERSION=2.0.0
ARG OPENCODE_VERSION=latest
ARG PNPM_VERSION=10

RUN apt-get update \
 && apt-get install -y --no-install-recommends git ca-certificates curl ripgrep jq less procps python3 make g++ unzip \
 && rm -rf /var/lib/apt/lists/*

RUN npm install -g --no-fund --no-audit \
      "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}" \
      "@openai/codex@${CODEX_VERSION}" \
      "opencode-ai@${OPENCODE_VERSION}" \
      "pnpm@${PNPM_VERSION}" \
      "@fission-ai/openspec@${OPENSPEC_VERSION}" \
 && npm cache clean --force

COPY peppa-agent.mjs bin/peppa-hook bin/peppa-mcp /usr/local/bin/
RUN chmod 755 /usr/local/bin/peppa-hook /usr/local/bin/peppa-mcp \
 # The runner runs as the host user (--user uid:gid): repos are owned by someone "else".
 && git config --system safe.directory '*' \
 && git config --system init.defaultBranch main \
 && mkdir -p /peppa/home /peppa/run && chmod 1777 /peppa/home

ENV HOME=/peppa/home \
    DISABLE_AUTOUPDATER=1 \
    CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
WORKDIR /peppa/home
LABEL org.opencontainers.image.title="peppa-runner" quest.telecom.peppa.component="runner"
