diff --git a/server-ce/Dockerfile b/server-ce/Dockerfile index 21bc965087..95d959fef8 100644 --- a/server-ce/Dockerfile +++ b/server-ce/Dockerfile @@ -34,10 +34,22 @@ ENV COREPACK_ENABLE_NETWORK=0 # re-fetching that small set of git deps. The valuable Berry cache # (server-ce-yarn-cache) stays persistent. YARN_NETWORK_CONCURRENCY=1 is kept # as cheap insurance against concurrent writes to the fresh cache. +# +# Preparing those git deps also makes Yarn Classic fetch esbuild's ~10 +# per-platform binaries, whose downloads occasionally arrive truncated ("the +# file appears to be corrupt" / missing .yarn-tarball.tgz). Since the tmpfs is +# fresh each build there is nothing to fall back to, so we wrap the step in a +# small retry loop that wipes the classic cache and re-fetches before failing. RUN --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \ --mount=type=tmpfs,target=/usr/local/share/.cache/yarn \ - --mount=type=tmpfs,target=/tmp node genScript install | YARN_NETWORK_CONCURRENCY=1 bash + --mount=type=tmpfs,target=/tmp \ + for i in 1 2 3; do \ + node genScript install | YARN_NETWORK_CONCURRENCY=1 bash && exit 0; \ + echo "==== install attempt $i failed; wiping Yarn Classic cache and retrying ===="; \ + rm -rf /usr/local/share/.cache/yarn/* 2>/dev/null || true; \ + done; \ + exit 1 # Add the actual source files # --------------------------- @@ -47,8 +59,15 @@ RUN --mount=type=cache,target=/root/.cache \ --mount=type=tmpfs,target=/usr/local/share/.cache/yarn \ --mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \ --mount=type=tmpfs,target=/tmp \ - node genScript compile | YARN_NETWORK_CONCURRENCY=1 bash || \ - (echo "==== PACK LOGS ====" && find /tmp -name pack.log -exec cat {} \; && exit 1) + for i in 1 2 3; do \ + node genScript compile | YARN_NETWORK_CONCURRENCY=1 bash && exit 0; \ + echo "==== compile attempt $i failed; wiping Yarn Classic cache and retrying ===="; \ + find /tmp -name pack.log -exec cat {} \; 2>/dev/null || true; \ + rm -rf /usr/local/share/.cache/yarn/* 2>/dev/null || true; \ + done; \ + echo "==== PACK LOGS (all attempts failed) ===="; \ + find /tmp -name pack.log -exec cat {} \; 2>/dev/null || true; \ + exit 1 # Copy runit service startup scripts to its location # -------------------------------------------------- ADD server-ce/runit /etc/service