Files
pi/Dockerfile
EislM0203andClaude Opus 4.7 415150c6a3 add k8s read-only troubleshooting extension
A new extensions/k8s/ extension giving the agent read-only Kubernetes
tools (k8s_get, k8s_describe, k8s_logs, k8s_events, k8s_top, k8s_explain,
k8s_context). Credentials: KUBE_TOKEN from the env, cluster URL from
KUBE_APISERVER env or ~/.pi/agent/k8s.json (editable via the /k8s panel).

All kubectl invocations go through one exec.ts chokepoint that prepends
--server/--token; the token never reaches any render path. A /k8s panel
runs reachability + can-i probes and lets the user set the cluster URL
(press e). A bundled "k8s" mode restricts the toolset to read + grep +
k8s_* for focused troubleshooting. README ships the SA + RBAC manifest.

Container changes (Dockerfile):
  - install kubectl
  - bake customizations into /app (OpenShell Landlock allowlists /app,
    not /opt) and chmod world-readable so the remapped sandbox uid can
    read them
  - openshell-policy.yaml: baseline filesystem/landlock/process policy

Also deletes the unused status-line.ts demo extension.

Known limitation: does NOT work inside an OpenShell sandbox yet —
OpenShell hardcodes the k8s control-plane ports (6443 et al.) as
universally blocked in its SSRF engine with no override. Documented in
extensions/k8s/README.md ("Why not OpenShell yet"). The extension works
when pi runs directly on a host with cluster access.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 21:34:44 +02:00

61 lines
2.7 KiB
Docker

# Runs the pi coding agent with these pi-customizations (extensions, agents,
# prompt templates) inside an NVIDIA OpenShell sandbox (Bring Your Own Container).
#
# Build + run via OpenShell: openshell sandbox create --from . -- pi
# The sandbox supervisor replaces CMD at runtime, so the start command ("pi")
# must be passed explicitly after `--`.
#
# Provider credentials (ANTHROPIC_API_KEY, etc.) are read from the environment
# at runtime and are intentionally NOT baked into the image.
FROM node:22-trixie-slim
# System tools:
# - iproute2 / iptables: OpenShell network-namespace management + bypass detection
# - git / openssh-client: used by the git-checkpoint and ssh-hosts extensions
# - ca-certificates / curl: TLS roots and a basic fetch tool
RUN apt-get update && apt-get install -y --no-install-recommends \
iproute2 iptables git openssh-client ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
# Install the pi coding agent globally. Override with --build-arg PI_VERSION=...
ARG PI_VERSION=0.75.3
RUN npm install -g @earendil-works/pi-coding-agent@${PI_VERSION}
# kubectl for the k8s extension. Pinned for reproducible builds; bump with
# --build-arg KUBECTL_VERSION=vX.Y.Z. The client is version-skew tolerant
# within ±1 minor against the target cluster.
ARG KUBECTL_VERSION=v1.29.3
RUN curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
-o /usr/local/bin/kubectl && \
chmod 0755 /usr/local/bin/kubectl
RUN userdel -r node && groupdel node 2>/dev/null; \
groupadd -g 1000 sandbox && \
useradd -u 1000 -g 1000 -d /sandbox -s /bin/bash sandbox
# Bake this pi-customizations package into the image at /app/pi-customizations.
# OpenShell's default Landlock policy allowlists /app for read access from the
# sandbox; /opt is not on the allowlist, so installing there causes
# "Permission denied" inside the sandbox even with permissive Unix perms.
COPY --chown=sandbox:sandbox . /app/pi-customizations
# Writable sandbox workdir owned by the sandbox user.
RUN install -d -o sandbox -g sandbox /sandbox
WORKDIR /sandbox
USER sandbox
# Install this package's runtime dependencies into /app/pi-customizations/node_modules.
# pi-provided imports (@earendil-works/*, typebox) resolve from pi's global install,
# but the websearch extension also pulls in linkedom + readability + turndown +
# turndown-plugin-gfm (declared in dependencies); those need to be present locally.
RUN cd /app/pi-customizations && npm ci --omit=dev --no-audit --no-fund
# Register the customizations with pi. A local-path install is recorded in
# ~/.pi/agent/settings.json without copying.
RUN pi install /app/pi-customizations
# Informational only — OpenShell's supervisor overrides this; launch with `-- pi`.
CMD ["pi"]