fix(ci): support legacy Claude Code package layout in image build

Handle Claude Code package versions that do not ship install.cjs by conditionally running the installer script only when present, so pinned-version image builds work for both legacy and newer package layouts.

Made-with: Cursor
This commit is contained in:
Darcy Liu 2026-04-25 23:25:19 +00:00
parent c79ff50563
commit 07e599c8ca

View file

@ -22,7 +22,12 @@ RUN apk add --no-cache \
echo "Installing @anthropic-ai/claude-code@${CLAUDE_CODE_RESOLVED_VERSION}" && \
npm install -g --ignore-scripts "@anthropic-ai/claude-code@${CLAUDE_CODE_RESOLVED_VERSION}" && \
CLAUDE_CODE_GLOBAL_ROOT="$(npm root -g)" && \
node "${CLAUDE_CODE_GLOBAL_ROOT}/@anthropic-ai/claude-code/install.cjs" && \
if [ -f "${CLAUDE_CODE_GLOBAL_ROOT}/@anthropic-ai/claude-code/install.cjs" ]; then \
node "${CLAUDE_CODE_GLOBAL_ROOT}/@anthropic-ai/claude-code/install.cjs"; \
else \
echo "No install.cjs found for @anthropic-ai/claude-code@${CLAUDE_CODE_RESOLVED_VERSION}; using legacy CLI layout."; \
fi && \
command -v claude >/dev/null && \
npm cache clean --force && \
groupadd --system claude && \
useradd --system --create-home --gid claude --shell /bin/bash claude && \