-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem
The Claude Code CLI install step in the sandbox Dockerfile (sandbox/Dockerfile, step 21/24) takes ~550 seconds (~9 minutes) on ARM64/Asahi Linux:
=> [21/24] RUN su - egg -c "curl -fsSL https://claude.ai/install.sh | bash -s -- 2.1.52" && ... 550.2s
This is the single slowest step in the image build and dominates total build time.
Root cause
The installer at https://claude.ai/install.sh downloads the full Claude Code CLI bundle (Node.js runtime + all dependencies, ~200-300MB). On ARM64 Linux, if pre-built native binaries aren't available for all npm dependencies, it falls back to source compilation (e.g., better-sqlite3, etc.), which is very slow.
Additionally, every version bump via the CLAUDE_CODE_VERSION build arg busts the Docker layer cache for this step and all subsequent steps.
Possible solutions
-
Move the install step earlier in the Dockerfile — currently at step 21/24, after
COPY . /opt/egg-runtime/(line 126) which busts cache on any source file change. Moving Claude Code install before frequently-changing COPY layers would improve cache hit rate. -
Multi-stage build — install Claude Code in a separate stage and
COPY --fromthe result, isolating it from other layer invalidation. -
Pre-download / cache the bundle — cache the Claude Code tarball in a Docker volume or build cache mount (
--mount=type=cache) so rebuilds don't re-download and re-extract. -
Check for ARM64 pre-built binary availability — confirm whether the native installer is doing source compilation and if a pre-built ARM64 binary is available.
Context
- Host: Asahi Linux (aarch64, kernel 6.17.12)
- Docker build is native ARM64 (no
--platformspecified, no QEMU emulation) - Relevant code:
sandbox/Dockerfile:156-170,sandbox/egg_lib/docker.py:555-639