Skip to content

Sandbox Docker build: Claude Code install step takes ~550s on ARM64 #898

@james-in-a-box

Description

@james-in-a-box

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

  1. 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.

  2. Multi-stage build — install Claude Code in a separate stage and COPY --from the result, isolating it from other layer invalidation.

  3. 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.

  4. 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 --platform specified, no QEMU emulation)
  • Relevant code: sandbox/Dockerfile:156-170, sandbox/egg_lib/docker.py:555-639

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions