瀏覽代碼

[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 <alf.eaton@overleaf.com>
GitOrigin-RevId: 0119c42ee8b13a0fca9373e40a27fc5b2a52d73b
Jakob Ackermann 1 年之前
父節點
當前提交
f6bd485863
共有 34 個文件被更改,包括 155 次插入139 次删除
  1. 0 0
      bin/shared/mongodb-init-replica-set.js
  2. 0 6
      develop/README.md
  3. 0 6
      develop/bin/init
  4. 8 0
      develop/docker-compose.yml
  5. 1 1
      docker-compose.yml
  6. 1 0
      server-ce/bin/shared
  7. 0 1
      server-ce/mongodb-init-replica-set.js
  8. 0 1
      server-ce/server-ce
  9. 1 1
      server-ce/test/docker-compose.yml
  10. 0 7
      services/chat/Makefile
  11. 10 5
      services/chat/docker-compose.ci.yml
  12. 10 5
      services/chat/docker-compose.yml
  13. 0 7
      services/contacts/Makefile
  14. 10 5
      services/contacts/docker-compose.ci.yml
  15. 10 5
      services/contacts/docker-compose.yml
  16. 0 7
      services/docstore/Makefile
  17. 10 5
      services/docstore/docker-compose.ci.yml
  18. 10 5
      services/docstore/docker-compose.yml
  19. 0 7
      services/document-updater/Makefile
  20. 10 5
      services/document-updater/docker-compose.ci.yml
  21. 10 5
      services/document-updater/docker-compose.yml
  22. 0 7
      services/history-v1/Makefile
  23. 1 1
      services/history-v1/buildscript.txt
  24. 10 5
      services/history-v1/docker-compose.ci.yml
  25. 10 5
      services/history-v1/docker-compose.yml
  26. 1 1
      services/history-v1/tsconfig.json
  27. 0 7
      services/notifications/Makefile
  28. 10 5
      services/notifications/docker-compose.ci.yml
  29. 10 5
      services/notifications/docker-compose.yml
  30. 0 7
      services/project-history/Makefile
  31. 10 5
      services/project-history/docker-compose.ci.yml
  32. 10 5
      services/project-history/docker-compose.yml
  33. 1 1
      services/web/docker-compose.ci.yml
  34. 1 1
      services/web/docker-compose.yml

+ 0 - 0
services/web/docker/mongodb-init-replica-set.js → bin/shared/mongodb-init-replica-set.js


+ 0 - 6
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

+ 0 - 6
develop/bin/init

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

+ 8 - 0
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:

+ 1 - 1
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:

+ 1 - 0
server-ce/bin/shared

@@ -0,0 +1 @@
+../../bin/shared/

+ 0 - 1
server-ce/mongodb-init-replica-set.js

@@ -1 +0,0 @@
-rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })

+ 0 - 1
server-ce/server-ce

@@ -1 +0,0 @@
-.

+ 1 - 1
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:

+ 0 - 7
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

+ 10 - 5
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

+ 10 - 5
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
 

+ 0 - 7
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

+ 10 - 5
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

+ 10 - 5
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
 

+ 0 - 7
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

+ 10 - 5
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"]

+ 10 - 5
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

+ 0 - 7
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

+ 10 - 5
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

+ 10 - 5
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
 

+ 0 - 7
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

+ 1 - 1
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/**/*

+ 10 - 5
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:

+ 10 - 5
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

+ 1 - 1
services/history-v1/tsconfig.json

@@ -15,4 +15,4 @@
     "test/**/*",
     "types"
   ]
-}
+}

+ 0 - 7
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

+ 10 - 5
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

+ 10 - 5
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
 

+ 0 - 7
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

+ 10 - 5
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

+ 10 - 5
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
 

+ 1 - 1
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:

+ 1 - 1
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: