Yarn 4 Migration (#32253)
Migrates the Overleaf monorepo package manager from npm (v11) to Yarn 4 (v4.9.1) using node-modules linker mode. GitOrigin-RevId: 50d32ab01955c15e29679eff9e9e9cfb897fab2d
This commit is contained in:
committed by
Copybot
parent
ed0fb0110a
commit
0d64a88a46
+14
-9
@@ -8,25 +8,30 @@ FROM $OVERLEAF_BASE_TAG
|
||||
|
||||
WORKDIR /overleaf
|
||||
|
||||
# Add required source files for npm install
|
||||
# -----------------------------------------
|
||||
COPY --parents libraries/*/package.json patches/ services/*/package.json tools/migrations/ package.json package-lock.json /overleaf/
|
||||
# Add required source files for yarn install
|
||||
# -------------------------------------------
|
||||
COPY --parents libraries/*/package.json .yarn/patches/ services/*/package.json tools/migrations/ package.json yarn.lock .yarnrc.yml /overleaf/
|
||||
COPY server-ce/genScript.js server-ce/services.js /overleaf/
|
||||
|
||||
# Install npm dependencies
|
||||
# ------------------------
|
||||
# Pre-install yarn via corepack so it is available at runtime for all users
|
||||
# -------------------------------------------------------------------------
|
||||
ENV COREPACK_HOME=/opt/corepack
|
||||
RUN corepack install
|
||||
|
||||
# Install yarn dependencies
|
||||
# -------------------------
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
--mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
|
||||
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
|
||||
--mount=type=tmpfs,target=/tmp node genScript install | bash
|
||||
|
||||
# Add the actual source files
|
||||
# ---------------------------
|
||||
COPY --parents libraries/ services/ tools/migrations/ /overleaf/
|
||||
RUN --mount=type=cache,target=/root/.cache \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
--mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
|
||||
--mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
|
||||
--mount=type=tmpfs,target=/tmp node genScript compile | bash
|
||||
--mount=type=tmpfs,target=/tmp \
|
||||
YARN_CACHE_FOLDER=/tmp/.yarn-cache node genScript compile | bash
|
||||
|
||||
# Copy runit service startup scripts to its location
|
||||
# --------------------------------------------------
|
||||
|
||||
@@ -33,6 +33,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y nodejs \
|
||||
&& corepack enable \
|
||||
\
|
||||
&& rm -rf \
|
||||
# We are adding a custom nginx config in the main Dockerfile.
|
||||
|
||||
@@ -5,7 +5,7 @@ console.log('set -ex')
|
||||
|
||||
switch (process.argv.pop()) {
|
||||
case 'install':
|
||||
console.log('npm install --omit=dev')
|
||||
console.log('yarn workspaces focus --all --production')
|
||||
break
|
||||
case 'compile':
|
||||
for (const service of services) {
|
||||
@@ -13,18 +13,18 @@ switch (process.argv.pop()) {
|
||||
switch (service.name) {
|
||||
case 'web':
|
||||
// precompile pug in background
|
||||
console.log('npm run precompile-pug &')
|
||||
console.log('yarn run precompile-pug &')
|
||||
console.log('pug_precompile=$!')
|
||||
|
||||
// Avoid downloading of cypress
|
||||
console.log('export CYPRESS_INSTALL_BINARY=0')
|
||||
|
||||
// install webpack and frontend dependencies
|
||||
console.log('npm install --include=dev')
|
||||
console.log('yarn install')
|
||||
// run webpack
|
||||
console.log('npm run webpack:production')
|
||||
console.log('yarn run webpack:production')
|
||||
// uninstall webpack and frontend dependencies
|
||||
console.log('npm prune --omit=dev')
|
||||
console.log('yarn workspaces focus --all --production')
|
||||
|
||||
// Wait for pug precompile to finish
|
||||
console.log('wait "$pug_precompile"')
|
||||
|
||||
@@ -9,5 +9,5 @@ fi
|
||||
|
||||
echo "Running migrations for $environment"
|
||||
cd /overleaf/tools/migrations
|
||||
/sbin/setuser www-data npm run migrations -- migrate -t "$environment"
|
||||
/sbin/setuser www-data yarn run migrations migrate -t "$environment"
|
||||
echo "Finished migrations"
|
||||
|
||||
@@ -35,7 +35,7 @@ test-e2e-native:
|
||||
CYPRESS_HOST_ADMIN_URL='http://127.0.0.1:3232' \
|
||||
CYPRESS_SAML_URL='http://127.0.0.1:3233' \
|
||||
CYPRESS_MAILTRAP_URL='http://127.0.0.1:3234' \
|
||||
npm run cypress:open
|
||||
yarn run cypress:open
|
||||
|
||||
# For testing "native" on Linux
|
||||
test-e2e-native-linux:
|
||||
|
||||
@@ -72,7 +72,7 @@ services:
|
||||
- USER_UID
|
||||
- USER_GID
|
||||
stop_grace_period: 0s
|
||||
entrypoint: npm
|
||||
entrypoint: yarn
|
||||
command: run cypress:run
|
||||
# See comment in Makefile regarding matching file paths
|
||||
working_dir: $PWD
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@isomorphic-git/lightning-fs": "^4.6.0",
|
||||
"@overleaf/promise-utils": "*",
|
||||
"@overleaf/validation-tools": "*",
|
||||
"@overleaf/promise-utils": "workspace:*",
|
||||
"@overleaf/validation-tools": "workspace:*",
|
||||
"@testing-library/cypress": "10.1.0",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/uuid": "^9.0.8",
|
||||
|
||||
Reference in New Issue
Block a user