Skip to content

Commit d18e4ad

Browse files
committed
fix(ci): add npm install retry logic to handle transient network failures
Split npm install commands with || retry pattern to handle ETIMEDOUT errors during Docker build in GitHub Actions. Also added npm config for longer fetch retry timeouts (30s-120s). BREAKING CHANGE: none Closes: #actions-23580886723
1 parent aef0899 commit d18e4ad

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

Dockerfile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,33 @@ RUN if command -v python3 >/dev/null 2>&1 && command -v uv >/dev/null 2>&1; then
8989
uv pip install --system --break-system-packages --no-cache notebooklm-py; \
9090
fi
9191

92+
# Helper function for retry npm install
93+
RUN --mount=type=cache,target=/root/.npm,uid=1000,gid=1000 \
94+
npm config set fetch-retries 3 && \
95+
npm config set fetch-retry-mintimeout 30000 && \
96+
npm config set fetch-retry-maxtimeout 120000
97+
9298
# Layer 3a: Core CLI tools (always installed)
9399
# Essential: openclaw (gateway) + openclaw-lark (Lark integration) + clawhub (Hub)
100+
# Split into individual commands with retry to handle transient network failures
101+
RUN --mount=type=cache,target=/root/.npm,uid=1000,gid=1000 \
102+
npm install -g openclaw@${OPENCLAW_VERSION} || npm install -g openclaw@${OPENCLAW_VERSION}
103+
94104
RUN --mount=type=cache,target=/root/.npm,uid=1000,gid=1000 \
95-
npm install -g openclaw@${OPENCLAW_VERSION} && \
96-
npm install -g @larksuite/openclaw-lark@latest && \
97-
npm install -g clawhub@latest && \
98-
chown -R node:node /home/node/.global
105+
npm install -g @larksuite/openclaw-lark@latest || npm install -g @larksuite/openclaw-lark@latest
106+
107+
RUN --mount=type=cache,target=/root/.npm,uid=1000,gid=1000 \
108+
npm install -g clawhub@latest || npm install -g clawhub@latest
109+
110+
RUN chown -R node:node /home/node/.global
99111

100112
# Layer 3b: AI Coding Tools (optional, ~500MB, skip for office variant)
101113
# Includes: claude-code, pi-coding-agent, opencode
102114
# Set INSTALL_AI_TOOLS=0 when building office variant
103115
RUN if [ "${INSTALL_AI_TOOLS}" = "1" ]; then \
104-
npm install -g @anthropic-ai/claude-code@latest && \
105-
npm install -g @mariozechner/pi-coding-agent && \
116+
--mount=type=cache,target=/root/.npm,uid=1000,gid=1000 \
117+
(npm install -g @anthropic-ai/claude-code@latest || npm install -g @anthropic-ai/claude-code@latest) && \
118+
(npm install -g @mariozechner/pi-coding-agent || npm install -g @mariozechner/pi-coding-agent) && \
106119
chown -R node:node /home/node/.global; \
107120
fi
108121

0 commit comments

Comments
 (0)