From bcf20abbc233d567d146d74cc11194ec84d3dc3e Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Thu, 15 Dec 2022 11:06:18 -0500 Subject: [PATCH] Merge pull request #10912 from overleaf/em-remove-mongo-from-spelling Remove mongo dependency from spelling GitOrigin-RevId: 1fff65610b7c64537697574ef35d9a7c9f295089 --- package-lock.json | 2 -- services/spelling/Dockerfile | 4 ++-- services/spelling/Makefile | 7 +++++-- services/spelling/app/js/mongodb.js | 28 ------------------------- services/spelling/buildscript.txt | 2 +- services/spelling/docker-compose.ci.yml | 9 -------- services/spelling/docker-compose.yml | 10 --------- services/spelling/package.json | 1 - 8 files changed, 8 insertions(+), 55 deletions(-) delete mode 100644 services/spelling/app/js/mongodb.js diff --git a/package-lock.json b/package-lock.json index 9481cadc4d..1ad451a1a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37863,7 +37863,6 @@ "bunyan": "^1.8.15", "express": "^4.17.1", "lru-cache": "^5.1.1", - "mongodb": "^3.6.0", "request": "^2.88.2", "underscore": "1.13.1" }, @@ -48170,7 +48169,6 @@ "express": "^4.17.1", "lru-cache": "^5.1.1", "mocha": "^8.4.0", - "mongodb": "^3.6.0", "request": "^2.88.2", "sandboxed-module": "2.0.4", "sinon": "^9.2.4", diff --git a/services/spelling/Dockerfile b/services/spelling/Dockerfile index 5cc51275b3..e942dfa27b 100644 --- a/services/spelling/Dockerfile +++ b/services/spelling/Dockerfile @@ -1,6 +1,6 @@ # This file was auto-generated, do not edit it directly. # Instead run bin/update_build_scripts from -# https://github.com/sharelatex/sharelatex-dev-environment +# https://github.com/overleaf/internal/ FROM node:16.17.1 as base @@ -24,7 +24,7 @@ COPY services/spelling/ /overleaf/services/spelling/ FROM app RUN mkdir -p cache \ - && chown node:node cache +&& chown node:node cache USER node CMD ["node", "--expose-gc", "app.js"] diff --git a/services/spelling/Makefile b/services/spelling/Makefile index e81c1c90c9..cbd35530cd 100644 --- a/services/spelling/Makefile +++ b/services/spelling/Makefile @@ -1,6 +1,6 @@ # This file was auto-generated, do not edit it directly. # Instead run bin/update_build_scripts from -# https://github.com/sharelatex/sharelatex-dev-environment +# https://github.com/overleaf/internal/ BUILD_NUMBER ?= local BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) @@ -83,6 +83,9 @@ ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif +benchmarks: + $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance npm run benchmarks + build: docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \ || docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \ @@ -110,4 +113,4 @@ publish: docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) -.PHONY: clean test test_unit test_acceptance test_clean build publish +.PHONY: clean test test_unit test_acceptance test_clean benchmarks build publish diff --git a/services/spelling/app/js/mongodb.js b/services/spelling/app/js/mongodb.js deleted file mode 100644 index f8bc7adcfb..0000000000 --- a/services/spelling/app/js/mongodb.js +++ /dev/null @@ -1,28 +0,0 @@ -const Settings = require('@overleaf/settings') -const { MongoClient, ObjectId } = require('mongodb') - -const clientPromise = MongoClient.connect( - Settings.mongo.url, - Settings.mongo.options -) - -let setupDbPromise -async function waitForDb() { - if (!setupDbPromise) { - setupDbPromise = setupDb() - } - await setupDbPromise -} - -const db = {} -async function setupDb() { - const internalDb = (await clientPromise).db() - - db.spellingPreferences = internalDb.collection('spellingPreferences') -} - -module.exports = { - db, - ObjectId, - waitForDb, -} diff --git a/services/spelling/buildscript.txt b/services/spelling/buildscript.txt index 3989a30653..8b3c1263d2 100644 --- a/services/spelling/buildscript.txt +++ b/services/spelling/buildscript.txt @@ -1,6 +1,6 @@ spelling --data-dirs=cache ---dependencies=mongo +--dependencies= --docker-repos=gcr.io/overleaf-ops --env-add= --env-pass-through= diff --git a/services/spelling/docker-compose.ci.yml b/services/spelling/docker-compose.ci.yml index cc5d75f7b4..c963841005 100644 --- a/services/spelling/docker-compose.ci.yml +++ b/services/spelling/docker-compose.ci.yml @@ -27,9 +27,6 @@ services: MOCHA_GREP: ${MOCHA_GREP} NODE_ENV: test NODE_OPTIONS: "--unhandled-rejections=strict" - depends_on: - mongo: - condition: service_healthy user: node command: npm run test:acceptance:_run @@ -41,9 +38,3 @@ services: - ./:/tmp/build/ command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs . user: root - mongo: - image: mongo:4.4.16 - healthcheck: - test: "mongo --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 diff --git a/services/spelling/docker-compose.yml b/services/spelling/docker-compose.yml index 675237f39f..de353faa98 100644 --- a/services/spelling/docker-compose.yml +++ b/services/spelling/docker-compose.yml @@ -44,15 +44,5 @@ services: NODE_ENV: test NODE_OPTIONS: "--unhandled-rejections=strict" user: node - depends_on: - mongo: - condition: service_healthy command: npm run --silent test:acceptance - mongo: - image: mongo:4.4.16 - healthcheck: - test: "mongo --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 - diff --git a/services/spelling/package.json b/services/spelling/package.json index 2bd229f1ff..65e76da252 100644 --- a/services/spelling/package.json +++ b/services/spelling/package.json @@ -31,7 +31,6 @@ "bunyan": "^1.8.15", "express": "^4.17.1", "lru-cache": "^5.1.1", - "mongodb": "^3.6.0", "request": "^2.88.2", "underscore": "1.13.1" },