mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
[monorepo] avoid corepack network requests (#33502)
* [monorepo] avoid corepack network requests - Download yarn via corepack as the first step in all the docker files - Turn off networking in corepack - Do not run things in the upstream node image Instead, use the monorepo image, or base layer in all the services. - Always build the base layer when running tests (uses cache) * [monorepo] install corepack in shared place * [clsi-lb] remove unrelated changes * [web] add missing DC_RUN_FLAGS * [monorepo] only rebuild test images locally Also remove spurious build config in docker-compose.ci.yml. * [server-ce] test: make yarn files available to host-admin and e2e * [monorepo] put the corepack install snippet in a few more places GitOrigin-RevId: 38005016ae5a708e12295e246269d6c18fece937
This commit is contained in:
@@ -4,9 +4,13 @@
|
||||
|
||||
FROM node:24.14.1 AS base
|
||||
|
||||
WORKDIR /overleaf/services/document-updater
|
||||
# Corepack setup, shared between all the images.
|
||||
ENV PATH="/overleaf/node_modules/.bin:$PATH"
|
||||
RUN corepack enable
|
||||
ENV COREPACK_HOME=/opt/corepack
|
||||
RUN corepack enable && corepack install -g yarn@4.14.1
|
||||
ENV COREPACK_ENABLE_NETWORK=0
|
||||
|
||||
WORKDIR /overleaf/services/document-updater
|
||||
|
||||
# Google Cloud Storage needs a writable $HOME/.config for resumable uploads
|
||||
# (see https://googleapis.dev/nodejs/storage/latest/File.html#createWriteStream)
|
||||
|
||||
@@ -38,6 +38,16 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
|
||||
MOCHA_GREP=${MOCHA_GREP} \
|
||||
docker compose ${DOCKER_COMPOSE_FLAGS}
|
||||
|
||||
# Common flags for docker compose run.
|
||||
# --rm Tear down test runner container
|
||||
# --build Make sure that we use the latest base image
|
||||
# --quiet-build Hide build output
|
||||
ifeq ($(CI),true)
|
||||
DC_RUN_FLAGS := --rm
|
||||
else
|
||||
DC_RUN_FLAGS := --rm --build --quiet-build
|
||||
endif
|
||||
|
||||
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE ?= test_acceptance_$(BUILD_DIR_NAME)
|
||||
DOCKER_COMPOSE_TEST_ACCEPTANCE = \
|
||||
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE) $(DOCKER_COMPOSE)
|
||||
@@ -55,11 +65,11 @@ clean:
|
||||
|
||||
# Run the linting commands in the scope of the monorepo.
|
||||
# Eslint and prettier (plus some configs) are on the root.
|
||||
RUN_LINTING = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(HERE) -e PATH=$(MONOREPO)/node_modules/.bin:$$PATH --user node node:24.14.1 corepack yarn run --silent
|
||||
RUN_LINTING_MONOREPO = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(MONOREPO) -e PATH=$(MONOREPO)/node_modules/.bin:$$PATH --user node node:24.14.1 corepack yarn run --silent
|
||||
RUN_LINTING = ../../bin/run -w /overleaf/services/$(PROJECT_NAME) monorepo yarn run --silent
|
||||
RUN_LINTING_MONOREPO = ../../bin/run monorepo yarn run --silent
|
||||
|
||||
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) corepack yarn run --silent
|
||||
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) corepack yarn run --silent
|
||||
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache $(IMAGE_CI) yarn run --silent
|
||||
RUN_LINTING_CI_MONOREPO = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/document-updater/reports:/overleaf/services/document-updater/reports --volume $(MONOREPO)/node_modules/.cache:/overleaf/node_modules/.cache -w /overleaf $(IMAGE_CI) yarn run --silent
|
||||
|
||||
SHELLCHECK_OPTS = \
|
||||
--shell=bash \
|
||||
@@ -126,7 +136,7 @@ test: format lint typecheck shellcheck test_unit test_acceptance
|
||||
|
||||
test_unit:
|
||||
ifneq (,$(wildcard test/unit))
|
||||
$(DOCKER_COMPOSE_TEST_UNIT) run --rm test_unit
|
||||
$(DOCKER_COMPOSE_TEST_UNIT) run $(DC_RUN_FLAGS) test_unit
|
||||
endif
|
||||
|
||||
test_clean: test_unit_clean
|
||||
@@ -143,12 +153,12 @@ test_acceptance_debug: test_acceptance_clean test_acceptance_pre_run test_accept
|
||||
|
||||
test_acceptance_run:
|
||||
ifneq (,$(wildcard test/acceptance))
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run $(DC_RUN_FLAGS) test_acceptance
|
||||
endif
|
||||
|
||||
test_acceptance_run_debug:
|
||||
ifneq (,$(wildcard test/acceptance))
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run -p 127.0.0.9:19999:19999 --rm test_acceptance corepack yarn run --inspect=0.0.0.0:19999 --inspect-brk test:acceptance
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run -p 127.0.0.9:19999:19999 $(DC_RUN_FLAGS) test_acceptance yarn run --inspect=0.0.0.0:19999 --inspect-brk test:acceptance
|
||||
endif
|
||||
|
||||
test_clean: test_acceptance_clean
|
||||
@@ -157,11 +167,11 @@ test_acceptance_clean:
|
||||
|
||||
test_acceptance_pre_run:
|
||||
ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run $(DC_RUN_FLAGS) test_acceptance test/acceptance/js/scripts/pre-run
|
||||
endif
|
||||
|
||||
benchmarks:
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance corepack yarn run benchmarks
|
||||
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run $(DC_RUN_FLAGS) test_acceptance yarn run benchmarks
|
||||
|
||||
build:
|
||||
docker build \
|
||||
|
||||
@@ -28,7 +28,6 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
test_acceptance:
|
||||
build: .
|
||||
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||
environment:
|
||||
CI:
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
|
||||
services:
|
||||
test_unit:
|
||||
image: node:24.14.1
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: services/document-updater/Dockerfile
|
||||
target: base
|
||||
volumes:
|
||||
- .:/overleaf/services/document-updater
|
||||
- ../../node_modules:/overleaf/node_modules
|
||||
@@ -28,7 +31,7 @@ services:
|
||||
ANALYTICS_QUEUES_REDIS_HOST: redis_test
|
||||
ANALYTICS_QUEUES_BQ_SINK_REDIS_HOST: redis_test
|
||||
entrypoint: /overleaf/bin/shared/wait_for_it mongo:27017 --timeout=60 --
|
||||
command: corepack yarn run --silent test:unit
|
||||
command: yarn run --silent test:unit
|
||||
user: node
|
||||
depends_on:
|
||||
mongo:
|
||||
@@ -37,7 +40,10 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
test_acceptance:
|
||||
image: node:24.14.1
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: services/document-updater/Dockerfile
|
||||
target: base
|
||||
volumes:
|
||||
- .:/overleaf/services/document-updater
|
||||
- ../../node_modules:/overleaf/node_modules
|
||||
@@ -69,7 +75,7 @@ services:
|
||||
redis_test:
|
||||
condition: service_healthy
|
||||
entrypoint: /overleaf/bin/shared/wait_for_it mongo:27017 --timeout=60 --
|
||||
command: corepack yarn run --silent test:acceptance
|
||||
command: yarn run --silent test:acceptance
|
||||
|
||||
redis_test:
|
||||
image: redis:7.4.8
|
||||
|
||||
Reference in New Issue
Block a user