feat(sandbox): install document + DS tooling for vendored skills

The docx/pdf/pptx/xlsx skills' scripts assume a working set of Python
libraries (pypdf, pdfplumber, reportlab, openpyxl, lxml, defusedxml,
Pillow, markitdown) and native tools (soffice headless, pdftoppm). Without
them, first-turn invocations of those skills fail with ImportError — and
the egress allowlist's pypi.org entry can't save us because pip install
on every turn adds latency and exercises an attack surface we'd rather
not hit on the critical path.

Bakes everything into the image:
  - libreoffice-{core,writer,calc,impress}: drops the GUI/Java bloat of
    the meta package while keeping headless conversion for all three
    office formats. Adds ~500 MB vs ~800+ MB for the full meta.
  - poppler-utils + fonts-dejavu: pdftoppm binary, pdf2image backend,
    and baseline glyph set so rendered PDFs aren't empty boxes.
  - pip: pypdf pdfplumber pdf2image reportlab Pillow openpyxl
    python-docx python-pptx pandas numpy matplotlib lxml defusedxml
    markitdown[pptx]. Also covers the explicit DS ask (pandas/numpy/
    matplotlib) so ad-hoc analysis doesn't hit pip on first use.
  - npm -g docx: the JS library the docx skill prefers for generating
    richly formatted new documents.

Final image is ~4.6 GB (up from ~1 GB). LibreOffice is the dominant term.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thomas Friedel 2026-04-18 23:49:08 +02:00
parent 5c41f57f0b
commit 05d53ade55
1 changed files with 33 additions and 0 deletions

View File

@ -23,6 +23,39 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends bubblewrap socat git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Native deps for the document skills:
# libreoffice-{core,writer,calc,impress} — headless `soffice` for .doc↔.docx
# conversion, tracked-change acceptance, xlsx recalc, and pptx thumbs.
# poppler-utils — pdftoppm binary + pdf2image Python backend.
# fonts-dejavu — baseline sans/serif so rendered PDFs aren't blank boxes.
# The LibreOffice subpackages total ~500 MB; installing the core meta
# package would add Java + GUI deps we never use. Pandoc (docx→markdown
# reading path) is already in the base image.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libreoffice-core libreoffice-writer libreoffice-calc \
libreoffice-impress \
poppler-utils fonts-dejavu \
&& rm -rf /var/lib/apt/lists/*
# Python libraries used by the skill scripts + standard data-science
# tooling so ad-hoc analysis doesn't require a per-turn `pip install`
# (which would exercise the egress allowlist every time and slow the
# first response). Installed system-wide into the base image's Python
# 3.12 under /usr/local (not PEP 668 managed, so no --break-system
# flag needed).
RUN pip3 install --no-cache-dir \
pypdf pdfplumber pdf2image reportlab Pillow \
openpyxl python-docx python-pptx \
pandas numpy matplotlib \
lxml defusedxml \
'markitdown[pptx]'
# Node package for the docx skill's "Creating New Documents" path —
# docx-js is preferred over python-docx when generating richly formatted
# documents from scratch (tables of contents, footnotes, columns, etc.).
RUN npm install -g docx
# Vendor a curated set of Anthropic skills into /opt/claude-skills. Each
# chat's CLAUDE_CONFIG_DIR/.claude/skills/ symlinks here at runtime, so all
# users share a read-only copy without per-chat duplication. To update the