Two independent sets of fixes.
## Disk: stop the growth, no UI this round
The dangling-snapshot sweep was already correct and was never the leak. The
leak is that every `docker commit` **stacks** a layer and nothing compacts one:
a file deleted after it has been committed becomes a whiteout, not free bytes.
24 conditions trigger recreation+commit, so changing one settings field costs a
multi-gigabyte layer for the life of the project. One project was measured with
14 stacked commit layers, ~5.1 GB above its base.
* **Scrub the writable layer before every commit** (`docker/container.rs`,
`SNAPSHOT_SCRUB_PATHS` / `scrub_writable_layer`). The one moment those bytes
are still free to drop is before the commit that captures them. Measured on
one container's 4.48 GB pending layer: 3.0 GB of agent scratchpad under
`/tmp/claude-*`, the terminal drag-drop staging area (256 MiB per file, with
no `rm` for it anywhere in the repo), a PNG per pasted image, and the apt
lists/cache/logs that `browser_view/install.rs` and `triple-c-playwright-heal`
leave behind with no `apt-get clean`. A hardcoded list, never a heuristic:
`/workspace/{mount_name}` is a host bind mount and nothing here may reach one,
and the three `/tmp` globs cannot select the read-only `.host-ca`/`.host-aws`
mounts. Failure is a log line — a scrub must never block a snapshot.
* **Cap container logs** (`capped_log_config`). There was no `LogConfig`
anywhere, so containers ran on the daemon's unbounded `json-file` default.
Deliberately *not* wired into `container_needs_recreation`: participating
would recreate every project once, and a recreation costs a commit, which is
the thing being fixed. Picked up on the next natural recreation.
* **Make superseded base images sweepable** (`container/Dockerfile`). It carried
no `LABEL` at all, so `orphan_sweep_filters`' `dangling` + `triple-c.managed`
pair provably could not match one — ~11.9 GB observed stranded. Stamping
`triple-c.managed=true` is the whole fix; the sweep needed no change.
`create_container` writes the new `triple-c.base` key explicitly empty, or
Docker's label inheritance plus `docker commit` would make every snapshot
claim to be a base image. `force: false` stays, and now says why.
* **Sweep at startup** (`lib.rs`), not only after recreation: probes first
(a probe pins an image the unforced sweep then refuses), pins second, sweep
last. `sweep_orphaned_snapshots_logged` exists because all three callers threw
the report away — `reclaimed_bytes`, `failed` and `unavailable` included.
* **Reap migration leftovers.** `rollback_migration` retagged and orphaned the
migrated snapshot with no sweep. Stale `pre-migration-*` pins are now
age-reaped by scanning the tag pattern rather than trusting the state file —
`migration_store::load` reports an unparseable record as absent, which
stranded a 4-12 GB pin nothing could name again; `load` now moves a corrupt
record aside so `has_record` is trustworthy. A pin whose migration is still
awaiting confirmation is never reaped at any age. The probe container's
removal was a plain statement after an await, so a dropped future (an app quit
mid-migration) leaked a container pinning a multi-gigabyte image; it is a
`Drop` guard now, with `reap_probe_containers` for the case where the process
itself dies.
* **Prune scheduler logs.** `remove` deleted a task's JSON but never its log
directory, and the task runner appended uncapped `claude -p` output.
* **Fix the delete copy.** It said "the container, config volume, and stored
credentials"; it removes *both* volumes and the snapshot image.
No prune UI, and no unfiltered `prune_images`/`prune_volumes` anywhere — the
daemon is shared with the user's unrelated work.
## Claude Code settings: two invented keys, one inverted default, one sticky bug
Verified against code.claude.com/docs/en/settings-reference.md and env-vars.md.
* `effort` -> **`effortLevel`**, the key Claude Code actually reads; the old one
was written and silently ignored. `xhigh` added to the dropdown.
* `focusMode` -> **`viewMode: "focus"`**. `focusMode` was invented. The real key
does exactly what the existing UI hint already described.
* **Session recap was inverted.** Claude Code's recap is on by default, so
`CLAUDE_CODE_ENABLE_AWAY_SUMMARY=1`-when-enabled was a no-op and the control
could never turn the recap *off*. The field is renamed to
`session_recap_disabled` rather than reused: reusing the name with the
opposite meaning would have read every stored `enable_session_recap: false` —
which is every project that never touched the control — as "the user turned
this off".
* **The stickiness, which is the important one.** Keys were emitted only when
non-default, and the entrypoint *merges* into a settings.json on a persisted
volume, so switching a setting off omitted its key, the merge preserved the
stale on-value, and the setting stayed on until a destructive Reset. The fix
already existed in the same file — the sandbox block is emitted
unconditionally for exactly this reason — and is now applied to all five keys.
A key whose neutral state is *unset* (`tui`, `effortLevel`, `viewMode`,
`awaySummaryEnabled`) is emitted as JSON `null` and the entrypoint deletes it,
because a stand-in value is not neutral: `tui: "default"` pins the classic
renderer where unset lets Claude Code choose, and `viewMode: "default"`
overrides the user's own sticky `/focus` choice.
* The same stickiness existed, unnoticed, in the **env vars**: `docker commit`
bakes container env into the snapshot image, so a `=1` written once rode it
forever. All four are now emitted on every create, extracted into
`claude_code_env_vars` and unit tested. Two use an empty value for "off"
rather than `0`, because they outrank a setting the user can change from
inside their own container and Triple-C's default must not overrule a
`/config` choice it never asked about.
* TUI mode is now a genuine three-way choice (automatic / classic / fullscreen),
which the always-emitted key makes both necessary and possible.
`merge_claude_code_settings` is untouched by choice: a project-level OFF still
cannot override a globally-ON setting.
Tests: 364 frontend (+5), 308 Rust (+23), covering the scrub path list and
script, log rotation, pin reaping, and that toggling a setting off actually
clears a previously-set ON value.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBq2rGum6GX7xXgsas1fDc
442 lines
24 KiB
Docker
442 lines
24 KiB
Docker
FROM ubuntu:24.04
|
|
|
|
# ── Provenance labels ────────────────────────────────────────────────────────
|
|
# Without these the base image carries no labels at all, and
|
|
# `sweep_orphaned_snapshots` (app/src-tauri/src/docker/container.rs) filters on
|
|
# `dangling=true` **and** `triple-c.managed=true` — so a superseded base image,
|
|
# left untagged when a newer build claims `triple-c-sandbox:latest`, could never
|
|
# match and was never collected. ~11.9 GB of stranded base images was measured
|
|
# on one developer's daemon this way.
|
|
#
|
|
# `triple-c.managed=true` is what makes them sweepable. Note that Docker merges
|
|
# an image's labels into the containers created from it and `docker commit`
|
|
# copies a container's labels onto the image, so this value also arrives on
|
|
# every container and every snapshot — which is harmless, because
|
|
# `create_container` writes the same key explicitly anyway.
|
|
#
|
|
# `triple-c.base=true` marks *this* image specifically, so a base image can be
|
|
# told apart from a project snapshot without parsing repository names.
|
|
LABEL triple-c.managed=true
|
|
LABEL triple-c.base=true
|
|
|
|
# Multi-arch: builds for linux/amd64 and linux/arm64 (Apple Silicon)
|
|
# Avoid interactive prompts during package install
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# ── System packages ──────────────────────────────────────────────────────────
|
|
# The shell retry loop handles transient mirror-sync failures where
|
|
# archive.ubuntu.com returns stale Packages.gz files with mismatched hashes
|
|
# during hourly resyncs. Clearing /var/lib/apt/lists/* between attempts
|
|
# forces a fresh fetch.
|
|
RUN for i in 1 2 3 4 5; do \
|
|
apt-get -o Acquire::Retries=3 update && break; \
|
|
echo "apt-get update failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& apt-get install -y --no-install-recommends \
|
|
git \
|
|
curl \
|
|
wget \
|
|
openssh-client \
|
|
build-essential \
|
|
ripgrep \
|
|
jq \
|
|
sudo \
|
|
ca-certificates \
|
|
libnss3-tools \
|
|
gnupg \
|
|
locales \
|
|
unzip \
|
|
pkg-config \
|
|
libssl-dev \
|
|
cron \
|
|
bubblewrap \
|
|
socat \
|
|
iproute2 \
|
|
wireguard-tools \
|
|
iptables \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# `libnss3-tools` above provides `certutil`. Chrome/Chromium read neither
|
|
# /etc/ssl/certs nor $SSL_CERT_FILE — they have their own NSS database at
|
|
# ~/.pki/nssdb — so without it the browser-view pane cannot be made to trust a
|
|
# corporate CA, no matter what the system trust store says. entrypoint.sh
|
|
# degrades to a warning if it is ever missing.
|
|
|
|
# `iproute2`, `wireguard-tools` and `iptables` above are what the VPN support
|
|
# toggle (`vpn_support_enabled`) grants capability *for*. That toggle hands a
|
|
# project CAP_NET_ADMIN and /dev/net/tun; without `ip` there is then no way to
|
|
# add a route, and without `wg` no way to build the tunnel those two exist to
|
|
# serve — a capability with nothing able to use it.
|
|
#
|
|
# They are baked rather than left to a runtime `apt-get install` for the same
|
|
# reason as the Playwright libraries below: the writable layer is re-paid after
|
|
# every Reset and lost on base-image migration. A hand-installed `wg` therefore
|
|
# works right up until an upgrade, then disappears and takes the tunnel with it
|
|
# — silently, since a VPN that fails to come up looks exactly like one that was
|
|
# never started.
|
|
#
|
|
# Measured against the *current base image*, since a bare ubuntu:24.04 also
|
|
# pulls libelf1t64 and netbase, which this base already has, and so over-reports
|
|
# by ~258 kB: **+12 packages, 7,203 kB on amd64**. The same set on arm64 is
|
|
# ~14.4 MB — the package list is identical on both arches, the binaries are
|
|
# simply larger (measured as 14.7 MB on arm64 ubuntu:24.04, less that 258 kB).
|
|
#
|
|
# ## Why `iptables`, and not `nftables`
|
|
#
|
|
# `wireguard-tools` declares `Recommends: nftables | iptables`, which the
|
|
# `--no-install-recommends` above strips. That is not cosmetic: `wg-quick`'s
|
|
# `add_default()` runs whenever a config has `AllowedIPs = 0.0.0.0/0` — i.e.
|
|
# every stock full-tunnel config every provider hands out — and it shells out to
|
|
# a firewall backend with no `type -p` guard. Measured with neither installed:
|
|
#
|
|
# [#] iptables-restore -n
|
|
# /usr/bin/wg-quick: line 32: iptables-restore: command not found
|
|
# wg-quick EXIT=127
|
|
#
|
|
# `nftables` looks like the better pick — wg-quick prefers it, it is first in
|
|
# that Recommends, it is half the size — and it is the wrong one. wg-quick picks
|
|
# nft *unconditionally* when present (`if type -p nft`, line 241), so installing
|
|
# it makes the iptables path unreachable; and its nft ruleset needs three
|
|
# expression families where the iptables path needs one. Isolating them on a
|
|
# WSL2 host, the two connmark rules install fine and this is what fails:
|
|
#
|
|
# nft add rule ... fib saddr type != local drop
|
|
# Error: Could not process rule: No such file or directory
|
|
# ^^^^^^^^^^^^^^ needs nft_fib_ipv4
|
|
#
|
|
# The choice therefore turns on which kernel symbol each path needs, and the two
|
|
# are not equally safe to bet on. `xt_CONNMARK` (iptables) was present in every
|
|
# kernel config examined — LinuxKit's for both arches, and WSL2's from 6.6.
|
|
# `nft_fib_ipv4` (nftables) was absent from the LinuxKit config read here, and a
|
|
# later review argued Docker Desktop has since enabled it and no longer builds
|
|
# from that config at all. That may well be true; it could not be settled from a
|
|
# Linux host, and it is the point: nftables' viability varies by Docker Desktop
|
|
# version in a way nobody here can pin down, while iptables' requirement did not
|
|
# vary anywhere it was checked.
|
|
#
|
|
# So `iptables` is chosen for being robust to that uncertainty rather than for
|
|
# beating nftables on any particular host. If nft_fib_ipv4 is present, wg-quick
|
|
# never reaches the iptables path and this costs 1.6 MB and nothing else; if it
|
|
# is absent, this is the difference between a working full tunnel and none.
|
|
#
|
|
# The residual gap is WSL2 before 6.6, which has neither symbol. Nothing
|
|
# installable in the container changes that — but `wsl --update` does, and moves
|
|
# the host to a far newer kernel. Add the routes with `ip route` in the meantime;
|
|
# that needs no firewall backend on any platform.
|
|
#
|
|
# ## What this still does not fix
|
|
#
|
|
# `wireguard-tools` only *Suggests* `openresolv | resolvconf`, so neither is
|
|
# installed, and every provider's stock config carries a `DNS =` line. That
|
|
# fails in `set_dns()`, *before* the firewall step, so it takes split tunnels
|
|
# down too:
|
|
#
|
|
# [#] resolvconf -a wg0 -m 0 -x
|
|
# /usr/bin/wg-quick: line 32: resolvconf: command not found
|
|
#
|
|
# Deliberately not fixed here: `openresolv` has no installation candidate on
|
|
# noble, and `resolvconf` resolves only by pulling in systemd-resolved — a
|
|
# resolver daemon and systemd units, into a container with no systemd. Strip the
|
|
# `DNS =` line and set the resolver another way. Documented in HOW-TO-USE.md.
|
|
|
|
# Remove default ubuntu user to free UID 1000 for host-user remapping
|
|
RUN if id ubuntu >/dev/null 2>&1; then userdel -r ubuntu 2>/dev/null || userdel ubuntu; fi \
|
|
&& if getent group ubuntu >/dev/null 2>&1; then groupdel ubuntu 2>/dev/null || true; fi
|
|
|
|
# Set UTF-8 locale
|
|
RUN locale-gen en_US.UTF-8
|
|
ENV LANG=en_US.UTF-8
|
|
ENV LC_ALL=en_US.UTF-8
|
|
|
|
# ── GitHub CLI ───────────────────────────────────────────────────────────────
|
|
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
|
| dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
|
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
|
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
|
|
> /etc/apt/sources.list.d/github-cli.list \
|
|
&& for i in 1 2 3 4 5; do \
|
|
apt-get -o Acquire::Retries=3 update && break; \
|
|
echo "apt-get update failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& apt-get install -y gh \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── Node.js LTS (22.x) + pnpm ───────────────────────────────────────────────
|
|
# Configure NodeSource repo manually (not via their setup_22.x script, which
|
|
# runs an internal apt-get update without retries and silently falls through
|
|
# to Ubuntu's default nodejs 18 — missing npm — on mirror-sync failures).
|
|
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
|
|
| gpg --dearmor -o /usr/share/keyrings/nodesource.gpg \
|
|
&& chmod a+r /usr/share/keyrings/nodesource.gpg \
|
|
&& echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" \
|
|
> /etc/apt/sources.list.d/nodesource.list \
|
|
&& for i in 1 2 3 4 5; do \
|
|
apt-get -o Acquire::Retries=3 update && break; \
|
|
echo "apt-get update failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& apt-get install -y nodejs \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& npm install -g pnpm
|
|
|
|
# ── Browser runtime libraries (Chromium / Google Chrome) ────────────────────
|
|
# Chromium links against a set of shared libraries Ubuntu's base image does not
|
|
# ship — libnss3, libgbm1, libatk*, libasound2t64, libcups2t64, libpango,
|
|
# libdrm2 and friends. Without them `playwright install chromium` downloads a
|
|
# browser that then dies at launch with "Host system is missing dependencies:
|
|
# libnss3.so", which reads like a Playwright bug and is not one. Installing
|
|
# google-chrome-stable used to look like the fix only because apt pulled these
|
|
# in as *its* dependencies.
|
|
#
|
|
# ## Why baked, and why only the libraries
|
|
#
|
|
# A runtime `apt-get install` lands in the container's writable layer: it is
|
|
# re-paid after every project Reset, and it is *lost* on base-image migration,
|
|
# which replays apt from a manifest against the new base. The browsers
|
|
# themselves live in ~/.cache/ms-playwright, inside the home volume, and survive
|
|
# both — so the runtime approach converges on the worst state, a 400 MB browser
|
|
# present with its libraries gone. Baking the libraries and leaving the browsers
|
|
# out puts each half where it already persists.
|
|
#
|
|
# Browser binaries are deliberately NOT baked: they are large, they are
|
|
# version-coupled to whatever Playwright the user installs, and the home volume
|
|
# already keeps them.
|
|
#
|
|
# ## Why `install-deps` rather than a hand-written apt list
|
|
#
|
|
# Playwright names its own dependencies, so the list cannot silently rot. That
|
|
# matters more than usual on Ubuntu 24.04, whose 64-bit-time_t transition
|
|
# renamed a swathe of these packages (libasound2 → libasound2t64, libatk1.0-0 →
|
|
# libatk1.0-0t64, libglib2.0-0 → libglib2.0-0t64, …); a hardcoded list drifts
|
|
# into "E: Unable to locate package" build failures, and a list that predates a
|
|
# new Chromium dependency drifts into exactly the launch failure this layer
|
|
# exists to prevent.
|
|
#
|
|
# Verified on a real `--platform linux/arm64` build of this file, not assumed:
|
|
# it resolves and installs there too (99 packages on both arches), and the
|
|
# --dry-run assertion below passes. Worth checking rather than assuming:
|
|
# Playwright looks its dependency list up under `<distro><version>-<arch>`, so
|
|
# arm64 is a separate lookup that could have missed.
|
|
#
|
|
# ## What it costs
|
|
#
|
|
# Measured with this layer applied on top of an otherwise identical image
|
|
# (linux/amd64, playwright 1.62.1): **+99 packages, +334 MiB unpacked, +119 MiB
|
|
# compressed** — the image goes 2950 → 3284 MiB unpacked, 759 → 878 MiB
|
|
# compressed. (`docker history` calls the layer 361 MB, i.e. 344 MiB; the
|
|
# difference is tar metadata `du` doesn't count.)
|
|
#
|
|
# Where it goes, by dpkg Installed-Size:
|
|
# ~213 MiB libllvm20 + mesa-libgallium + libicu74. Not optional and not
|
|
# avoidable by trimming the list: libgbm1, which Chromium genuinely
|
|
# needs, Depends on mesa-libgallium, which Depends on libllvm20.
|
|
# ~94 MiB Playwright's `tools` group — xvfb and the CJK/emoji fonts. Kept:
|
|
# the base image ships no fonts at all, so without them every page
|
|
# this feature exists to display renders as tofu, and xvfb is what
|
|
# lets a *headed* browser run in here.
|
|
# the rest Chromium's own library closure.
|
|
#
|
|
# An explicit apt list of just `chromium`'s dependencies measures 247 MiB
|
|
# installed against install-deps' 341 MiB, so hand-maintaining one would save
|
|
# ~94 MiB. Not worth owning the drift; if you disagree, derive the list from
|
|
# `install-deps --dry-run chromium` and pin the Playwright version you took it
|
|
# from in a comment here.
|
|
#
|
|
# The retry loop is for the same transient mirror-sync failures the other apt
|
|
# layers guard against; install-deps runs its own un-retried `apt-get update`
|
|
# internally. `npx --yes` is what makes it non-interactive, and the version it
|
|
# resolved is printed so a build log says which Playwright named this set.
|
|
#
|
|
# Placed immediately after Node (npx is its only prerequisite) and well above
|
|
# the shim COPYs, so editing a shim at the bottom of this file does not re-run a
|
|
# multi-hundred-megabyte apt install.
|
|
#
|
|
# `--dry-run` afterwards is the build-time assertion, and it is not decoration:
|
|
# on a platform Playwright's table does not cover, `install-deps` prints a
|
|
# warning and returns having installed **nothing, with exit status 0**. Without
|
|
# this check that failure mode would ship an image whose build log looked clean.
|
|
# `--dry-run` exits non-zero if any required package is still missing.
|
|
RUN npx --yes playwright@latest --version \
|
|
&& ok=0 \
|
|
&& for i in 1 2 3 4 5; do \
|
|
if npx --yes playwright@latest install-deps chromium; then ok=1; break; fi; \
|
|
echo "install-deps failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& [ "$ok" = 1 ] \
|
|
&& npx --yes playwright@latest install-deps --dry-run chromium \
|
|
&& rm -rf /var/lib/apt/lists/* /root/.npm
|
|
|
|
# ── Python 3 + pip + uv + ruff ──────────────────────────────────────────────
|
|
RUN for i in 1 2 3 4 5; do \
|
|
apt-get -o Acquire::Retries=3 update && break; \
|
|
echo "apt-get update failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& apt-get install -y --no-install-recommends \
|
|
python3 \
|
|
python3-pip \
|
|
python3-venv \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── Docker CLI (not daemon) ─────────────────────────────────────────────────
|
|
RUN install -m 0755 -d /etc/apt/keyrings \
|
|
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
|
|
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
|
|
&& chmod a+r /etc/apt/keyrings/docker.gpg \
|
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
|
|
> /etc/apt/sources.list.d/docker.list \
|
|
&& for i in 1 2 3 4 5; do \
|
|
apt-get -o Acquire::Retries=3 update && break; \
|
|
echo "apt-get update failed (attempt $i), retrying in 10s..."; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
sleep 10; \
|
|
done \
|
|
&& apt-get install -y docker-ce-cli \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── AWS CLI v2 ───────────────────────────────────────────────────────────────
|
|
RUN ARCH=$(uname -m) && \
|
|
curl "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o "awscliv2.zip" && \
|
|
unzip -q awscliv2.zip && \
|
|
./aws/install && \
|
|
rm -rf awscliv2.zip aws
|
|
|
|
# ── Non-root user with passwordless sudo ─────────────────────────────────────
|
|
RUN useradd -m -s /bin/bash -u 1000 claude \
|
|
&& echo "claude ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/claude \
|
|
&& chmod 0440 /etc/sudoers.d/claude
|
|
|
|
# ── Mount points (created as root, owned by claude) ──────────────────────────
|
|
RUN mkdir -p /workspace && chown claude:claude /workspace
|
|
|
|
# ── Rust (installed as claude user) ──────────────────────────────────────────
|
|
USER claude
|
|
WORKDIR /home/claude
|
|
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
ENV PATH="/home/claude/.cargo/bin:${PATH}"
|
|
|
|
# Install uv and ruff for claude user
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
|
&& curl -LsSf https://astral.sh/ruff/install.sh | sh
|
|
ENV PATH="/home/claude/.local/bin:/home/claude/.cargo/bin:${PATH}"
|
|
|
|
# ── Claude Code ──────────────────────────────────────────────────────────────
|
|
RUN curl -fsSL https://claude.ai/install.sh | bash
|
|
ENV PATH="/home/claude/.claude/bin:${PATH}"
|
|
|
|
RUN mkdir -p /home/claude/.claude /home/claude/.ssh
|
|
|
|
WORKDIR /workspace
|
|
|
|
# ── Switch back to root for entrypoint (handles UID/GID remapping) ─────────
|
|
USER root
|
|
|
|
# ── OSC 52 clipboard support ─────────────────────────────────────────────
|
|
# Provides xclip/xsel/pbcopy shims that emit OSC 52 escape sequences,
|
|
# allowing programs inside the container to copy to the host clipboard.
|
|
COPY osc52-clipboard /usr/local/bin/osc52-clipboard
|
|
RUN chmod +x /usr/local/bin/osc52-clipboard \
|
|
&& ln -sf /usr/local/bin/osc52-clipboard /usr/local/bin/xclip \
|
|
&& ln -sf /usr/local/bin/osc52-clipboard /usr/local/bin/xsel \
|
|
&& ln -sf /usr/local/bin/osc52-clipboard /usr/local/bin/pbcopy
|
|
|
|
# ── Audio capture shim (voice mode) ────────────────────────────────────────
|
|
# Provides fake rec/arecord that read PCM from a FIFO instead of a real mic,
|
|
# allowing Claude Code voice mode to work inside the container.
|
|
COPY audio-shim /usr/local/bin/audio-shim
|
|
RUN chmod +x /usr/local/bin/audio-shim \
|
|
&& ln -sf /usr/local/bin/audio-shim /usr/local/bin/rec \
|
|
&& ln -sf /usr/local/bin/audio-shim /usr/local/bin/arecord
|
|
|
|
# ── URL relay shim (host browser) ───────────────────────────────────────────
|
|
# Container-side stand-in for a browser. Emits an OSC 7777 escape sequence that
|
|
# Triple-C's terminal front-end intercepts and turns into a host-browser open.
|
|
# Installed under every name a CLI conventionally consults, plus $BROWSER.
|
|
#
|
|
# What Ubuntu 24.04's base actually ships (verified, not assumed):
|
|
# sensible-browser PRESENT (/usr/bin/sensible-browser, from sensible-utils)
|
|
# xdg-open absent (xdg-utils is not installed)
|
|
# www-browser absent (no update-alternatives entry)
|
|
# x-www-browser absent (no update-alternatives entry)
|
|
# gnome-open / gvfs-open / kde-open / open absent
|
|
#
|
|
# So the three names that need real handling, not just a symlink:
|
|
# * sensible-browser is a dpkg-owned file. A /usr/local/bin symlink would
|
|
# only shadow it for PATH lookups, leaving absolute-path callers on the
|
|
# stock script — so it is dpkg-diverted and replaced. (The stock script
|
|
# does defer to $BROWSER, but only when $BROWSER is set; diverting makes
|
|
# the behaviour unconditional and survives package upgrades.)
|
|
# * www-browser / x-www-browser are update-alternatives names, so they are
|
|
# registered as alternatives rather than hand-symlinked. This matters:
|
|
# sensible-browser probes /usr/bin/x-www-browser by absolute path, which
|
|
# only exists if something registered the alternative. `--set` pins them
|
|
# to manual mode so a later `apt install firefox` cannot steal them and
|
|
# point the container at a browser it has no display to run.
|
|
# * xdg-open is diverted pre-emptively so that if someone later installs
|
|
# xdg-utils inside the container, dpkg unpacks to xdg-open.distrib and
|
|
# our relay keeps /usr/bin/xdg-open.
|
|
COPY triple-c-open /usr/local/bin/triple-c-open
|
|
RUN chmod +x /usr/local/bin/triple-c-open \
|
|
&& for name in xdg-open sensible-browser gnome-open gvfs-open kde-open open; do \
|
|
ln -sf /usr/local/bin/triple-c-open "/usr/local/bin/$name"; \
|
|
done \
|
|
&& dpkg-divert --local --rename --divert /usr/bin/sensible-browser.distrib \
|
|
--add /usr/bin/sensible-browser \
|
|
&& ln -sf /usr/local/bin/triple-c-open /usr/bin/sensible-browser \
|
|
&& dpkg-divert --local --rename --divert /usr/bin/xdg-open.distrib \
|
|
--add /usr/bin/xdg-open \
|
|
&& ln -sf /usr/local/bin/triple-c-open /usr/bin/xdg-open \
|
|
&& update-alternatives --install /usr/bin/x-www-browser x-www-browser \
|
|
/usr/local/bin/triple-c-open 200 \
|
|
&& update-alternatives --set x-www-browser /usr/local/bin/triple-c-open \
|
|
&& update-alternatives --install /usr/bin/www-browser www-browser \
|
|
/usr/local/bin/triple-c-open 200 \
|
|
&& update-alternatives --set www-browser /usr/local/bin/triple-c-open
|
|
|
|
# $BROWSER must be an image-level ENV, not just an entrypoint export: terminal
|
|
# sessions are separate `docker exec`s, which inherit the container's config
|
|
# env and see nothing the entrypoint exported into its own process. The
|
|
# entrypoint additionally forwards it into the cron environment file.
|
|
ENV BROWSER=/usr/local/bin/triple-c-open
|
|
|
|
COPY triple-c-sso-refresh /usr/local/bin/triple-c-sso-refresh
|
|
RUN chmod +x /usr/local/bin/triple-c-sso-refresh
|
|
|
|
COPY mission-control /opt/mission-control
|
|
|
|
# Skills that ship with a Triple-C feature rather than with Mission Control.
|
|
# entrypoint.sh installs them into ~/.claude/skills/ when the feature that owns
|
|
# them is enabled, and removes them when it is not — a skill telling an agent to
|
|
# build a tunnel in a container that no longer has CAP_NET_ADMIN is worse than
|
|
# no skill at all. Staged in /opt because ~/.claude is a volume mount: an image
|
|
# copy underneath it would be masked from the project's first start onward.
|
|
COPY skills /opt/triple-c-skills
|
|
# `find`, not a `*/*.sh` glob: the glob fails the build the day a skill ships
|
|
# without a script, which is a legitimate thing for a skill to do.
|
|
RUN find /opt/triple-c-skills -name '*.sh' -exec chmod +x {} +
|
|
|
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
COPY triple-c-scheduler /usr/local/bin/triple-c-scheduler
|
|
RUN chmod +x /usr/local/bin/triple-c-scheduler
|
|
# Lives in /usr/local/bin rather than under /home/claude on purpose: the home
|
|
# directory is the mount point of the project's home volume, so an image copy
|
|
# of it is masked after the project's first start and can never be updated
|
|
# again. /usr/local/bin rides the snapshot and is replaced on migration, which
|
|
# is what lets a fix to this script reach an existing project at all.
|
|
COPY triple-c-playwright-heal /usr/local/bin/triple-c-playwright-heal
|
|
RUN chmod +x /usr/local/bin/triple-c-playwright-heal
|
|
COPY triple-c-task-runner /usr/local/bin/triple-c-task-runner
|
|
RUN chmod +x /usr/local/bin/triple-c-task-runner
|
|
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|