diff --git a/server-ce/Dockerfile b/server-ce/Dockerfile index 91255ba280..21bc965087 100644 --- a/server-ce/Dockerfile +++ b/server-ce/Dockerfile @@ -25,14 +25,18 @@ ENV COREPACK_ENABLE_NETWORK=0 # Install yarn dependencies # ------------------------- -# YARN_NETWORK_CONCURRENCY=1 serialises Yarn's fetch step. The git-sourced -# @replit/codemirror-* deps are prepared with Yarn Classic, which pulls *all* -# esbuild platform binaries into the one shared /usr/local/share/.cache/yarn -# folder; preparing several of them in parallel races and corrupts that cache -# (EEXIST / missing .yarn-tarball.tgz). Serialising the fetch removes the race. +# The git-sourced @replit/codemirror-* deps are prepared with Yarn Classic, +# whose cache lives in /usr/local/share/.cache/yarn. We mount that as a *tmpfs* +# (fresh every build) rather than a persistent BuildKit cache: when it was +# persistent, BuildKit would garbage-collect/evict part of it between builds, +# leaving a half-populated cache that Yarn Classic then tripped over (missing +# .yarn-tarball.tgz / EEXIST). A clean cache per build is reliable; the cost is +# 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. RUN --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \ - --mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache-v3 \ + --mount=type=tmpfs,target=/usr/local/share/.cache/yarn \ --mount=type=tmpfs,target=/tmp node genScript install | YARN_NETWORK_CONCURRENCY=1 bash # Add the actual source files @@ -40,7 +44,7 @@ RUN --mount=type=cache,target=/root/.cache \ COPY --parents libraries/ services/ tools/migrations/ /overleaf/ RUN --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \ - --mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache-v3 \ + --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 || \