-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (81 loc) · 4.15 KB
/
Copy pathDockerfile
File metadata and controls
93 lines (81 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Build: docker build -t studio-sandbox:local -f packages/sandbox/image/Dockerfile packages/sandbox
FROM oven/bun:1.3.13-debian
ARG NODE_MAJOR=22
ARG DENO_VERSION=v1.46.3
# `locales` + generated `en_US.UTF-8` is load-bearing: repos using
# `embedded-postgres` refuse to init without it.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash ca-certificates curl git gnupg locales python3 python3-pip \
ripgrep unzip \
&& sed -i 's/^#\s*en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen \
&& curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSL https://deno.land/install.sh \
| DENO_INSTALL=/opt/deno sh -s -- -y "${DENO_VERSION}" \
&& ln -s /opt/deno/bin/deno /usr/local/bin/deno \
&& corepack enable \
&& corepack prepare yarn@stable --activate \
&& corepack prepare pnpm@latest --activate
# Office tooling used by /mnt/skills/public/* document skills:
# - LibreOffice headless for pptx/xlsx/docx → PDF conversion (rasterization,
# formula recalc, accept-tracked-changes).
# - Poppler suite for PDF inspection and page-image extraction (pdftoppm,
# pdfinfo, pdftotext, pdfimages, pdfdetach, pdffonts).
# - dbus + a generated /etc/machine-id so soffice doesn't warn on every call.
# - DejaVu + Liberation fonts so soffice renders text instead of fallback
# tofu glyphs.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libreoffice-impress poppler-utils dbus \
fonts-dejavu-core fonts-liberation \
&& rm -rf /var/lib/apt/lists/* \
&& dbus-uuidgen > /etc/machine-id
# Python libraries used by /mnt/skills/public/* helper scripts.
RUN pip3 install --break-system-packages --no-cache-dir \
python-pptx python-docx openpyxl pypdf Pillow
ENV LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8
# Convert silent stalls (NAT instance replacement, PMTUD blackholes, mid-stream
# packet drops) into fast errors that the daemon's clone retry loop can catch.
# Without this, libcurl waits on TCP keepalive (~2h default) and the clone
# hangs at "Receiving objects" indefinitely.
RUN git config --system http.lowSpeedLimit 1000 \
&& git config --system http.lowSpeedTime 30
# Non-root sandbox user. The bun image comes with a 'bun' user (UID 1000),
# but we drop privileges further by replacing it with a 'sandbox' user.
RUN userdel --remove bun \
&& useradd --create-home --uid 1000 --user-group --shell /bin/bash sandbox \
&& mkdir -p /app /opt/sandbox-daemon \
&& chown -R sandbox:sandbox /app /opt/sandbox-daemon
WORKDIR /app
# node-pty is a native addon. The daemon bundle marks it `--external`, so it
# must be installed inside the image. `bun init -y` creates a minimal
# package.json; `bun add` triggers node-pty's prebuilt-binary download (or
# builds from source for archs without prebuilts). build-essential + python3
# are required for the node-gyp fallback on architectures (e.g. linux-arm64)
# that have no pre-built binary. build-essential is removed after the build to
# keep the layer lean. The `find … chmod +x` step ensures the spawn-helper
# binary is executable (relevant on macOS-targeted prebuilds; no-op on Linux).
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& cd /opt/sandbox-daemon \
&& bun init -y \
&& bun add node-pty@^1.0.0 \
&& find /opt/sandbox-daemon/node_modules/node-pty -name "spawn-helper" -exec chmod +x {} \; \
&& chown -R sandbox:sandbox /opt/sandbox-daemon \
&& apt-get purge -y --auto-remove build-essential
COPY --chown=sandbox:sandbox daemon/dist/daemon.js /opt/sandbox-daemon/daemon.js
COPY --chown=sandbox:sandbox image/skills /mnt/skills/public
# Expose skill helper scripts as bare commands. Wrappers in skills/_bin/
# are tiny shell shims; symlinking them into /usr/local/bin lets the model
# run e.g. `pptx-thumbnail deck.pptx` instead of typing the full python path.
RUN chmod +x /mnt/skills/public/_bin/* \
&& ln -s /mnt/skills/public/_bin/* /usr/local/bin/
ENV IS_SANDBOX=1
USER sandbox
EXPOSE 9000
CMD ["bun", "/opt/sandbox-daemon/daemon.js"]