Skip to content

Commit 729b8a8

Browse files
committed
Improve npm installation reliability in Dockerfile by implementing a retry mechanism for npm ci. This change allows for up to five attempts with increasing wait times between retries, addressing potential mid-stream read timeouts during dependency installation.
1 parent 255a903 commit 729b8a8

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ COPY client ./client
2727
# Multi-arch / QEMU: slow reads can hit ETIMEDOUT on large tarballs (e.g. typescript).
2828
# Retry/timeouts + single socket help; plain `npm ci` (no BuildKit cache mount) so HA Supervisor
2929
# and other non-BuildKit builders succeed.
30+
# Outer retries: npm may not restart the whole install after a mid-stream read timeout.
3031
ENV npm_config_cache=/root/.npm \
3132
npm_config_fetch_retries=20 \
3233
npm_config_fetch_retry_mintimeout=20000 \
3334
npm_config_fetch_retry_maxtimeout=120000 \
3435
npm_config_fetch_timeout=600000 \
3536
npm_config_maxsockets=1
36-
RUN npm ci
37+
RUN i=0; \
38+
while [ "$$i" -lt 5 ]; do \
39+
i=$$((i + 1)); \
40+
npm ci && exit 0; \
41+
echo "npm ci failed (attempt $$i/5), retrying in $$((i * 20))s..."; \
42+
sleep $$((i * 20)); \
43+
done; \
44+
exit 1
3745

3846
# Build workspaces in order
3947
RUN npm run build -w shared

0 commit comments

Comments
 (0)