From f6bd485863a68a762f0e6d5e2b11add560a1c38a Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 17 Mar 2025 08:17:22 +0000 Subject: [PATCH] [misc] align initializing of mongodb replica set (#24287) * [misc] align initializing of mongodb replica set * [misc] fix volumes for mono container in dev-env * Remove duplicate volumes key --------- Co-authored-by: Alf Eaton GitOrigin-RevId: 0119c42ee8b13a0fca9373e40a27fc5b2a52d73b --- .../shared}/mongodb-init-replica-set.js | 0 develop/README.md | 6 ------ develop/bin/init | 6 ------ develop/docker-compose.yml | 8 ++++++++ docker-compose.yml | 2 +- server-ce/bin/shared | 1 + server-ce/mongodb-init-replica-set.js | 1 - server-ce/server-ce | 1 - server-ce/test/docker-compose.yml | 2 +- services/chat/Makefile | 7 ------- services/chat/docker-compose.ci.yml | 15 ++++++++++----- services/chat/docker-compose.yml | 15 ++++++++++----- services/contacts/Makefile | 7 ------- services/contacts/docker-compose.ci.yml | 15 ++++++++++----- services/contacts/docker-compose.yml | 15 ++++++++++----- services/docstore/Makefile | 7 ------- services/docstore/docker-compose.ci.yml | 15 ++++++++++----- services/docstore/docker-compose.yml | 15 ++++++++++----- services/document-updater/Makefile | 7 ------- services/document-updater/docker-compose.ci.yml | 15 ++++++++++----- services/document-updater/docker-compose.yml | 15 ++++++++++----- services/history-v1/Makefile | 7 ------- services/history-v1/buildscript.txt | 2 +- services/history-v1/docker-compose.ci.yml | 15 ++++++++++----- services/history-v1/docker-compose.yml | 15 ++++++++++----- services/history-v1/tsconfig.json | 2 +- services/notifications/Makefile | 7 ------- services/notifications/docker-compose.ci.yml | 15 ++++++++++----- services/notifications/docker-compose.yml | 15 ++++++++++----- services/project-history/Makefile | 7 ------- services/project-history/docker-compose.ci.yml | 15 ++++++++++----- services/project-history/docker-compose.yml | 15 ++++++++++----- services/web/docker-compose.ci.yml | 2 +- services/web/docker-compose.yml | 2 +- 34 files changed, 155 insertions(+), 139 deletions(-) rename {services/web/docker => bin/shared}/mongodb-init-replica-set.js (100%) delete mode 100755 develop/bin/init create mode 120000 server-ce/bin/shared delete mode 100644 server-ce/mongodb-init-replica-set.js delete mode 120000 server-ce/server-ce diff --git a/services/web/docker/mongodb-init-replica-set.js b/bin/shared/mongodb-init-replica-set.js similarity index 100% rename from services/web/docker/mongodb-init-replica-set.js rename to bin/shared/mongodb-init-replica-set.js diff --git a/develop/README.md b/develop/README.md index 49f7d63350..568259c4e3 100644 --- a/develop/README.md +++ b/develop/README.md @@ -11,12 +11,6 @@ bin/build > [!NOTE] > If Docker is running out of RAM while building the services in parallel, create a `.env` file in this directory containing `COMPOSE_PARALLEL_LIMIT=1`. -Next, initialize the database: - -```shell -bin/init -``` - Then start the services: ```shell diff --git a/develop/bin/init b/develop/bin/init deleted file mode 100755 index 4cb2a4eae1..0000000000 --- a/develop/bin/init +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -docker compose up --detach mongo -curl --max-time 10 --retry 5 --retry-delay 5 --retry-all-errors --silent --output /dev/null localhost:27017 -docker compose exec mongo mongosh --eval "rs.initiate({ _id: 'overleaf', members: [{ _id: 0, host: 'mongo:27017' }] })" -docker compose down mongo diff --git a/develop/docker-compose.yml b/develop/docker-compose.yml index 075583cb1a..d0dc8ec6da 100644 --- a/develop/docker-compose.yml +++ b/develop/docker-compose.yml @@ -94,6 +94,14 @@ services: - "127.0.0.1:27017:27017" # for debugging volumes: - mongo-data:/data/db + - ../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 notifications: build: diff --git a/docker-compose.yml b/docker-compose.yml index a762bf73e1..08d6db6fe7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,7 +103,7 @@ services: command: '--replSet overleaf' volumes: - ~/mongo_data:/data/db - - ./server-ce/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + - ./bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js environment: MONGO_INITDB_DATABASE: sharelatex extra_hosts: diff --git a/server-ce/bin/shared b/server-ce/bin/shared new file mode 120000 index 0000000000..418b1bc599 --- /dev/null +++ b/server-ce/bin/shared @@ -0,0 +1 @@ +../../bin/shared/ \ No newline at end of file diff --git a/server-ce/mongodb-init-replica-set.js b/server-ce/mongodb-init-replica-set.js deleted file mode 100644 index 8d993774c7..0000000000 --- a/server-ce/mongodb-init-replica-set.js +++ /dev/null @@ -1 +0,0 @@ -rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] }) diff --git a/server-ce/server-ce b/server-ce/server-ce deleted file mode 120000 index 945c9b46d6..0000000000 --- a/server-ce/server-ce +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/server-ce/test/docker-compose.yml b/server-ce/test/docker-compose.yml index 0e5d520fae..43f494a084 100644 --- a/server-ce/test/docker-compose.yml +++ b/server-ce/test/docker-compose.yml @@ -38,7 +38,7 @@ services: image: mongo:6.0 command: '--replSet overleaf' volumes: - - ../mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + - ../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js environment: MONGO_INITDB_DATABASE: sharelatex extra_hosts: diff --git a/services/chat/Makefile b/services/chat/Makefile index 0eb3adea63..94f0afb567 100644 --- a/services/chat/Makefile +++ b/services/chat/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/chat/docker-compose.ci.yml b/services/chat/docker-compose.ci.yml index 6f1a608534..51eb64d126 100644 --- a/services/chat/docker-compose.ci.yml +++ b/services/chat/docker-compose.ci.yml @@ -26,7 +26,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started user: node command: npm run test:acceptance @@ -41,7 +41,12 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/chat/docker-compose.yml b/services/chat/docker-compose.yml index 8fec13cbb2..b830d25453 100644 --- a/services/chat/docker-compose.yml +++ b/services/chat/docker-compose.yml @@ -38,14 +38,19 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started command: npm run --silent test:acceptance mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/contacts/Makefile b/services/contacts/Makefile index 351070e0b7..97a348d219 100644 --- a/services/contacts/Makefile +++ b/services/contacts/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/contacts/docker-compose.ci.yml b/services/contacts/docker-compose.ci.yml index 6f1a608534..51eb64d126 100644 --- a/services/contacts/docker-compose.ci.yml +++ b/services/contacts/docker-compose.ci.yml @@ -26,7 +26,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started user: node command: npm run test:acceptance @@ -41,7 +41,12 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/contacts/docker-compose.yml b/services/contacts/docker-compose.yml index 8cdedbe1ef..310220bd20 100644 --- a/services/contacts/docker-compose.yml +++ b/services/contacts/docker-compose.yml @@ -38,14 +38,19 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started command: npm run --silent test:acceptance mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/docstore/Makefile b/services/docstore/Makefile index f06ad3c14c..6efd053025 100644 --- a/services/docstore/Makefile +++ b/services/docstore/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/docstore/docker-compose.ci.yml b/services/docstore/docker-compose.ci.yml index a8847e8996..a1a9995f60 100644 --- a/services/docstore/docker-compose.ci.yml +++ b/services/docstore/docker-compose.ci.yml @@ -29,7 +29,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started gcs: condition: service_healthy user: node @@ -46,10 +46,15 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 gcs: image: fsouza/fake-gcs-server:1.45.2 command: ["--port=9090", "--scheme=http"] diff --git a/services/docstore/docker-compose.yml b/services/docstore/docker-compose.yml index b170934f48..93a029b00a 100644 --- a/services/docstore/docker-compose.yml +++ b/services/docstore/docker-compose.yml @@ -41,7 +41,7 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started gcs: condition: service_healthy command: npm run --silent test:acceptance @@ -49,10 +49,15 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 gcs: image: fsouza/fake-gcs-server:1.45.2 diff --git a/services/document-updater/Makefile b/services/document-updater/Makefile index b8a3e1a02e..55f483fc89 100644 --- a/services/document-updater/Makefile +++ b/services/document-updater/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/document-updater/docker-compose.ci.yml b/services/document-updater/docker-compose.ci.yml index 332a9710ca..bdf10c9732 100644 --- a/services/document-updater/docker-compose.ci.yml +++ b/services/document-updater/docker-compose.ci.yml @@ -29,7 +29,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy user: node @@ -53,7 +53,12 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/document-updater/docker-compose.yml b/services/document-updater/docker-compose.yml index 7770e52d26..7dd27c9a39 100644 --- a/services/document-updater/docker-compose.yml +++ b/services/document-updater/docker-compose.yml @@ -41,7 +41,7 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy command: npm run --silent test:acceptance @@ -56,8 +56,13 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/history-v1/Makefile b/services/history-v1/Makefile index b9ab568b48..1f03a21f18 100644 --- a/services/history-v1/Makefile +++ b/services/history-v1/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/history-v1/buildscript.txt b/services/history-v1/buildscript.txt index 3b1c7d83de..f8c895901b 100644 --- a/services/history-v1/buildscript.txt +++ b/services/history-v1/buildscript.txt @@ -7,4 +7,4 @@ history-v1 --node-version=20.18.2 --public-repo=False --script-version=4.5.0 ---tsconfig-extra-includes=backup-deletion-app.mjs,backup-verifier-app.mjs,api/**/*,migrations/**/*,storage/**/* +--tsconfig-extra-includes=backup-deletion-app.mjs,backup-verifier-app.mjs,backup-worker-app.mjs,api/**/*,migrations/**/*,storage/**/* diff --git a/services/history-v1/docker-compose.ci.yml b/services/history-v1/docker-compose.ci.yml index 35c40bb7bb..7245ef14e2 100644 --- a/services/history-v1/docker-compose.ci.yml +++ b/services/history-v1/docker-compose.ci.yml @@ -40,7 +40,7 @@ services: - ./test/acceptance/certs:/certs depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy postgres: @@ -74,10 +74,15 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 postgres: image: postgres:10 environment: diff --git a/services/history-v1/docker-compose.yml b/services/history-v1/docker-compose.yml index 17dad0cb99..608dd1d325 100644 --- a/services/history-v1/docker-compose.yml +++ b/services/history-v1/docker-compose.yml @@ -57,7 +57,7 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy postgres: @@ -82,10 +82,15 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 postgres: image: postgres:10 diff --git a/services/history-v1/tsconfig.json b/services/history-v1/tsconfig.json index f130ebba8f..0e20309d3d 100644 --- a/services/history-v1/tsconfig.json +++ b/services/history-v1/tsconfig.json @@ -15,4 +15,4 @@ "test/**/*", "types" ] -} \ No newline at end of file +} diff --git a/services/notifications/Makefile b/services/notifications/Makefile index 82b5a3839a..8ca3f983ff 100644 --- a/services/notifications/Makefile +++ b/services/notifications/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/notifications/docker-compose.ci.yml b/services/notifications/docker-compose.ci.yml index 6f1a608534..51eb64d126 100644 --- a/services/notifications/docker-compose.ci.yml +++ b/services/notifications/docker-compose.ci.yml @@ -26,7 +26,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started user: node command: npm run test:acceptance @@ -41,7 +41,12 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/notifications/docker-compose.yml b/services/notifications/docker-compose.yml index ba54a3d38e..c0902fee2d 100644 --- a/services/notifications/docker-compose.yml +++ b/services/notifications/docker-compose.yml @@ -38,14 +38,19 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started command: npm run --silent test:acceptance mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/project-history/Makefile b/services/project-history/Makefile index 746c03fc86..5cde05ea46 100644 --- a/services/project-history/Makefile +++ b/services/project-history/Makefile @@ -116,13 +116,6 @@ test_acceptance_clean: $(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0 test_acceptance_pre_run: - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo - $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ - while ! mongosh --eval "db.version()" > /dev/null; do \ - echo "Waiting for Mongo..."; \ - sleep 1; \ - done; \ - mongosh --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' ifneq (,$(wildcard test/acceptance/js/scripts/pre-run)) $(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run endif diff --git a/services/project-history/docker-compose.ci.yml b/services/project-history/docker-compose.ci.yml index 332a9710ca..bdf10c9732 100644 --- a/services/project-history/docker-compose.ci.yml +++ b/services/project-history/docker-compose.ci.yml @@ -29,7 +29,7 @@ services: NODE_OPTIONS: "--unhandled-rejections=strict" depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy user: node @@ -53,7 +53,12 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/project-history/docker-compose.yml b/services/project-history/docker-compose.yml index c5b410b4fd..39c7ed9009 100644 --- a/services/project-history/docker-compose.yml +++ b/services/project-history/docker-compose.yml @@ -41,7 +41,7 @@ services: user: node depends_on: mongo: - condition: service_healthy + condition: service_started redis: condition: service_healthy command: npm run --silent test:acceptance @@ -56,8 +56,13 @@ services: mongo: image: mongo:6.0.13 command: --replSet overleaf - healthcheck: - test: "mongosh --quiet localhost/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 1)'" - interval: 1s - retries: 20 + volumes: + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + environment: + MONGO_INITDB_DATABASE: sharelatex + extra_hosts: + # Required when using the automatic database setup for initializing the + # replica set. This override is not needed when running the setup after + # starting up mongo. + - mongo:127.0.0.1 diff --git a/services/web/docker-compose.ci.yml b/services/web/docker-compose.ci.yml index 4d020d80dd..c277cc0e97 100644 --- a/services/web/docker-compose.ci.yml +++ b/services/web/docker-compose.ci.yml @@ -93,7 +93,7 @@ services: driver: none command: --replSet overleaf volumes: - - ./docker/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js environment: MONGO_INITDB_DATABASE: sharelatex extra_hosts: diff --git a/services/web/docker-compose.yml b/services/web/docker-compose.yml index 8594d9442a..c6a5aa7482 100644 --- a/services/web/docker-compose.yml +++ b/services/web/docker-compose.yml @@ -90,7 +90,7 @@ services: image: mongo:6.0.13 command: --replSet overleaf volumes: - - ./docker/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js + - ../../bin/shared/mongodb-init-replica-set.js:/docker-entrypoint-initdb.d/mongodb-init-replica-set.js environment: MONGO_INITDB_DATABASE: sharelatex extra_hosts: