Forráskód Böngészése

Merge pull request #10912 from overleaf/em-remove-mongo-from-spelling

Remove mongo dependency from spelling

GitOrigin-RevId: 1fff65610b7c64537697574ef35d9a7c9f295089
Eric Mc Sween 3 éve
szülő
commit
bcf20abbc2

+ 0 - 2
package-lock.json

@@ -37863,7 +37863,6 @@
         "bunyan": "^1.8.15",
         "bunyan": "^1.8.15",
         "express": "^4.17.1",
         "express": "^4.17.1",
         "lru-cache": "^5.1.1",
         "lru-cache": "^5.1.1",
-        "mongodb": "^3.6.0",
         "request": "^2.88.2",
         "request": "^2.88.2",
         "underscore": "1.13.1"
         "underscore": "1.13.1"
       },
       },
@@ -48170,7 +48169,6 @@
         "express": "^4.17.1",
         "express": "^4.17.1",
         "lru-cache": "^5.1.1",
         "lru-cache": "^5.1.1",
         "mocha": "^8.4.0",
         "mocha": "^8.4.0",
-        "mongodb": "^3.6.0",
         "request": "^2.88.2",
         "request": "^2.88.2",
         "sandboxed-module": "2.0.4",
         "sandboxed-module": "2.0.4",
         "sinon": "^9.2.4",
         "sinon": "^9.2.4",

+ 2 - 2
services/spelling/Dockerfile

@@ -1,6 +1,6 @@
 # This file was auto-generated, do not edit it directly.
 # This file was auto-generated, do not edit it directly.
 # Instead run bin/update_build_scripts from
 # 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
 FROM node:16.17.1 as base
 
 
@@ -24,7 +24,7 @@ COPY services/spelling/ /overleaf/services/spelling/
 
 
 FROM app
 FROM app
 RUN mkdir -p cache \
 RUN mkdir -p cache \
-    &&  chown node:node cache
+&&  chown node:node cache
 USER node
 USER node
 
 
 CMD ["node", "--expose-gc", "app.js"]
 CMD ["node", "--expose-gc", "app.js"]

+ 5 - 2
services/spelling/Makefile

@@ -1,6 +1,6 @@
 # This file was auto-generated, do not edit it directly.
 # This file was auto-generated, do not edit it directly.
 # Instead run bin/update_build_scripts from
 # Instead run bin/update_build_scripts from
-# https://github.com/sharelatex/sharelatex-dev-environment
+# https://github.com/overleaf/internal/
 
 
 BUILD_NUMBER ?= local
 BUILD_NUMBER ?= local
 BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
 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
 	$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
 endif
 endif
 
 
+benchmarks:
+	$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance npm run benchmarks
+
 build:
 build:
 	docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
 	docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
 		|| docker pull gcr.io/overleaf-ops/$(PROJECT_NAME):main-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)
 	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

+ 0 - 28
services/spelling/app/js/mongodb.js

@@ -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,
-}

+ 1 - 1
services/spelling/buildscript.txt

@@ -1,6 +1,6 @@
 spelling
 spelling
 --data-dirs=cache
 --data-dirs=cache
---dependencies=mongo
+--dependencies=
 --docker-repos=gcr.io/overleaf-ops
 --docker-repos=gcr.io/overleaf-ops
 --env-add=
 --env-add=
 --env-pass-through=
 --env-pass-through=

+ 0 - 9
services/spelling/docker-compose.ci.yml

@@ -27,9 +27,6 @@ services:
       MOCHA_GREP: ${MOCHA_GREP}
       MOCHA_GREP: ${MOCHA_GREP}
       NODE_ENV: test
       NODE_ENV: test
       NODE_OPTIONS: "--unhandled-rejections=strict"
       NODE_OPTIONS: "--unhandled-rejections=strict"
-    depends_on:
-      mongo:
-        condition: service_healthy
     user: node
     user: node
     command: npm run test:acceptance:_run
     command: npm run test:acceptance:_run
 
 
@@ -41,9 +38,3 @@ services:
       - ./:/tmp/build/
       - ./:/tmp/build/
     command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
     command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
     user: root
     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

+ 0 - 10
services/spelling/docker-compose.yml

@@ -44,15 +44,5 @@ services:
       NODE_ENV: test
       NODE_ENV: test
       NODE_OPTIONS: "--unhandled-rejections=strict"
       NODE_OPTIONS: "--unhandled-rejections=strict"
     user: node
     user: node
-    depends_on:
-      mongo:
-        condition: service_healthy
     command: npm run --silent test:acceptance
     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
-

+ 0 - 1
services/spelling/package.json

@@ -31,7 +31,6 @@
     "bunyan": "^1.8.15",
     "bunyan": "^1.8.15",
     "express": "^4.17.1",
     "express": "^4.17.1",
     "lru-cache": "^5.1.1",
     "lru-cache": "^5.1.1",
-    "mongodb": "^3.6.0",
     "request": "^2.88.2",
     "request": "^2.88.2",
     "underscore": "1.13.1"
     "underscore": "1.13.1"
   },
   },