GithubHelp home page GithubHelp logo

Comments (18)

l4rm4nd avatar l4rm4nd commented on June 4, 2024 4

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)

Why not use toolkit? http://github.com/overleaf/toolkit

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

Thanks for the feedback.

However, I want to use the docker compose version.

Your provided intructions do not fix the issue. Same error message appears.

from overleaf.

Guerric9018 avatar Guerric9018 commented on June 4, 2024 3

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.

I have the same problem as above, doesn't work for me... Still getting the same error

from overleaf.

Musicminion avatar Musicminion commented on June 4, 2024 2

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)

Why not use toolkit? http://github.com/overleaf/toolkit

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

from overleaf.

KK4BitsPerSecond avatar KK4BitsPerSecond commented on June 4, 2024 1

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.
I tried this and it did not work for me. Will give it another try, probably next weekend.
There has to be something I'm doing wrong.

from overleaf.

logocar3 avatar logocar3 commented on June 4, 2024 1

Date: 14.3.2024

I managed to make it work in Windows 11 with WSL 2 and Docker Desktop, had to finish following steps:

Modify original docker compose (https://github.com/overleaf/overleaf/blob/main/docker-compose.yml):

  • Add command: "--replSet overleaf" under mongo container
  • Add enviromental variables SHARELATEX_MONGO_URL and SHARELATEX_REDIS_HOST under sharelatex folder, with the same values as OVERLEAF_ variables. Note i added variables not replaced - no clue why it works, but works
  • Executed:
  docker compose up -d mongo
  docker exec -it mongo mongosh
  #inside mongosh, after waitinig some time:
  rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017"} ] })
  exit
  #outside mongosh
  docker compose up -d

I could not make following code work in Windows, so code above is the same as below but broken in steps:

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

from overleaf.

5huanghuai avatar 5huanghuai commented on June 4, 2024 1

I have encountered the same issue and have been unable to resolve it. I have already used a new Docker Compose file to create Docker containers, but I still encounter the same problem.

from overleaf.

senyai avatar senyai commented on June 4, 2024

And what do mongodb logs say?

from overleaf.

KK4BitsPerSecond avatar KK4BitsPerSecond commented on June 4, 2024

And what do mongodb logs say?

That would be helpful. Sorry.

Mongo Container Logs:

2024-02-12T15:45:41.309+0000 I NETWORK  [conn5122] received client metadata from 127.0.0.1:35158 conn5122: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:45:41.315+0000 I NETWORK  [conn5122] end connection 127.0.0.1:35158 (1 connection now open)
2024-02-12T15:45:51.445+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:50152 #5123 (2 connections now open)
2024-02-12T15:45:51.465+0000 I NETWORK  [conn5123] received client metadata from 127.0.0.1:50152 conn5123: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:45:51.470+0000 I NETWORK  [conn5123] end connection 127.0.0.1:50152 (1 connection now open)
2024-02-12T15:46:01.611+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:45550 #5124 (2 connections now open)
2024-02-12T15:46:01.629+0000 I NETWORK  [conn5124] received client metadata from 127.0.0.1:45550 conn5124: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:01.635+0000 I NETWORK  [conn5124] end connection 127.0.0.1:45550 (1 connection now open)
2024-02-12T15:46:11.780+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:47344 #5125 (2 connections now open)
2024-02-12T15:46:11.801+0000 I NETWORK  [conn5125] received client metadata from 127.0.0.1:47344 conn5125: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:11.807+0000 I NETWORK  [conn5125] end connection 127.0.0.1:47344 (1 connection now open)
2024-02-12T15:46:21.962+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43536 #5126 (2 connections now open)
2024-02-12T15:46:21.982+0000 I NETWORK  [conn5126] received client metadata from 127.0.0.1:43536 conn5126: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:21.987+0000 I NETWORK  [conn5126] end connection 127.0.0.1:43536 (1 connection now open)
2024-02-12T15:46:31.819+0000 I NETWORK  [conn5121] end connection 192.168.128.4:44718 (0 connections now open)
2024-02-12T15:46:32.102+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36952 #5127 (1 connection now open)
2024-02-12T15:46:32.103+0000 I NETWORK  [conn5127] received client metadata from 127.0.0.1:36952 conn5127: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:32.111+0000 I NETWORK  [conn5127] end connection 127.0.0.1:36952 (0 connections now open)
2024-02-12T15:46:34.351+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:42078 #5128 (1 connection now open)
2024-02-12T15:46:34.360+0000 I NETWORK  [conn5128] received client metadata from 192.168.128.4:42078 conn5128: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:46:42.249+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:34992 #5129 (2 connections now open)
2024-02-12T15:46:42.271+0000 I NETWORK  [conn5129] received client metadata from 127.0.0.1:34992 conn5129: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:42.287+0000 I NETWORK  [conn5129] end connection 127.0.0.1:34992 (1 connection now open)
2024-02-12T15:46:52.428+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:48314 #5130 (2 connections now open)
2024-02-12T15:46:52.447+0000 I NETWORK  [conn5130] received client metadata from 127.0.0.1:48314 conn5130: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:52.463+0000 I NETWORK  [conn5130] end connection 127.0.0.1:48314 (1 connection now open)
2024-02-12T15:47:02.597+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:49976 #5131 (2 connections now open)
2024-02-12T15:47:02.617+0000 I NETWORK  [conn5131] received client metadata from 127.0.0.1:49976 conn5131: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:02.623+0000 I NETWORK  [conn5131] end connection 127.0.0.1:49976 (1 connection now open)
2024-02-12T15:47:12.760+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:60100 #5132 (2 connections now open)
2024-02-12T15:47:12.777+0000 I NETWORK  [conn5132] received client metadata from 127.0.0.1:60100 conn5132: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:12.782+0000 I NETWORK  [conn5132] end connection 127.0.0.1:60100 (1 connection now open)
2024-02-12T15:47:22.911+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36824 #5133 (2 connections now open)
2024-02-12T15:47:22.930+0000 I NETWORK  [conn5133] received client metadata from 127.0.0.1:36824 conn5133: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:22.941+0000 I NETWORK  [conn5133] end connection 127.0.0.1:36824 (1 connection now open)
2024-02-12T15:47:33.091+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:50850 #5134 (2 connections now open)
2024-02-12T15:47:33.110+0000 I NETWORK  [conn5134] received client metadata from 127.0.0.1:50850 conn5134: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:33.115+0000 I NETWORK  [conn5134] end connection 127.0.0.1:50850 (1 connection now open)
2024-02-12T15:47:34.354+0000 I NETWORK  [conn5128] end connection 192.168.128.4:42078 (0 connections now open)
2024-02-12T15:47:36.986+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:58914 #5135 (1 connection now open)
2024-02-12T15:47:36.993+0000 I NETWORK  [conn5135] received client metadata from 192.168.128.4:58914 conn5135: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:47:43.262+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:53064 #5136 (2 connections now open)
2024-02-12T15:47:43.263+0000 I NETWORK  [conn5136] received client metadata from 127.0.0.1:53064 conn5136: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:43.268+0000 I NETWORK  [conn5136] end connection 127.0.0.1:53064 (1 connection now open)
2024-02-12T15:47:53.397+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43932 #5137 (2 connections now open)
2024-02-12T15:47:53.417+0000 I NETWORK  [conn5137] received client metadata from 127.0.0.1:43932 conn5137: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:53.423+0000 I NETWORK  [conn5137] end connection 127.0.0.1:43932 (1 connection now open)
2024-02-12T15:48:03.565+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:54276 #5138 (2 connections now open)
2024-02-12T15:48:03.585+0000 I NETWORK  [conn5138] received client metadata from 127.0.0.1:54276 conn5138: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:03.591+0000 I NETWORK  [conn5138] end connection 127.0.0.1:54276 (1 connection now open)
2024-02-12T15:48:13.723+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:56930 #5139 (2 connections now open)
2024-02-12T15:48:13.741+0000 I NETWORK  [conn5139] received client metadata from 127.0.0.1:56930 conn5139: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:13.746+0000 I NETWORK  [conn5139] end connection 127.0.0.1:56930 (1 connection now open)
2024-02-12T15:48:23.874+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:42930 #5140 (2 connections now open)
2024-02-12T15:48:23.893+0000 I NETWORK  [conn5140] received client metadata from 127.0.0.1:42930 conn5140: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:23.899+0000 I NETWORK  [conn5140] end connection 127.0.0.1:42930 (1 connection now open)
2024-02-12T15:48:34.052+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:40206 #5141 (2 connections now open)
2024-02-12T15:48:34.075+0000 I NETWORK  [conn5141] received client metadata from 127.0.0.1:40206 conn5141: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:34.090+0000 I NETWORK  [conn5141] end connection 127.0.0.1:40206 (1 connection now open)
2024-02-12T15:48:36.989+0000 I NETWORK  [conn5135] end connection 192.168.128.4:58914 (0 connections now open)
2024-02-12T15:48:39.710+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:56014 #5142 (1 connection now open)
2024-02-12T15:48:39.716+0000 I NETWORK  [conn5142] received client metadata from 192.168.128.4:56014 conn5142: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:48:44.227+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43020 #5143 (2 connections now open)
2024-02-12T15:48:44.245+0000 I NETWORK  [conn5143] received client metadata from 127.0.0.1:43020 conn5143: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:44.251+0000 I NETWORK  [conn5143] end connection 127.0.0.1:43020 (1 connection now open)
2024-02-12T15:48:54.386+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36766 #5144 (2 connections now open)
2024-02-12T15:48:54.405+0000 I NETWORK  [conn5144] received client metadata from 127.0.0.1:36766 conn5144: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:54.411+0000 I NETWORK  [conn5144] end connection 127.0.0.1:36766 (1 connection now open)
2024-02-12T15:49:04.548+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:42776 #5145 (2 connections now open)
2024-02-12T15:49:04.565+0000 I NETWORK  [conn5145] received client metadata from 127.0.0.1:42776 conn5145: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:04.570+0000 I NETWORK  [conn5145] end connection 127.0.0.1:42776 (1 connection now open)
2024-02-12T15:49:09.044+0000 I CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
2024-02-12T15:49:09.045+0000 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
2024-02-12T15:49:14.742+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:53200 #5146 (2 connections now open)
2024-02-12T15:49:14.761+0000 I NETWORK  [conn5146] received client metadata from 127.0.0.1:53200 conn5146: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:14.767+0000 I NETWORK  [conn5146] end connection 127.0.0.1:53200 (1 connection now open)
2024-02-12T15:49:24.909+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43054 #5147 (2 connections now open)
2024-02-12T15:49:24.930+0000 I NETWORK  [conn5147] received client metadata from 127.0.0.1:43054 conn5147: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:24.935+0000 I NETWORK  [conn5147] end connection 127.0.0.1:43054 (1 connection now open)
2024-02-12T15:49:35.075+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:59968 #5148 (2 connections now open)
2024-02-12T15:49:35.093+0000 I NETWORK  [conn5148] received client metadata from 127.0.0.1:59968 conn5148: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:35.099+0000 I NETWORK  [conn5148] end connection 127.0.0.1:59968 (1 connection now open)
2024-02-12T15:49:39.711+0000 I NETWORK  [conn5142] end connection 192.168.128.4:56014 (0 connections now open)
2024-02-12T15:49:42.365+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:44096 #5149 (1 connection now open)
2024-02-12T15:49:42.373+0000 I NETWORK  [conn5149] received client metadata from 192.168.128.4:44096 conn5149: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:49:45.237+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:41838 #5150 (2 connections now open)
2024-02-12T15:49:45.259+0000 I NETWORK  [conn5150] received client metadata from 127.0.0.1:41838 conn5150: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:45.274+0000 I NETWORK  [conn5150] end connection 127.0.0.1:41838 (1 connection now open)
2024-02-12T15:49:55.430+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:48996 #5151 (2 connections now open)
2024-02-12T15:49:55.450+0000 I NETWORK  [conn5151] received client metadata from 127.0.0.1:48996 conn5151: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:55.455+0000 I NETWORK  [conn5151] end connection 127.0.0.1:48996 (1 connection now open)
2024-02-12T15:50:05.595+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:44462 #5152 (2 connections now open)
2024-02-12T15:50:05.614+0000 I NETWORK  [conn5152] received client metadata from 127.0.0.1:44462 conn5152: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:05.619+0000 I NETWORK  [conn5152] end connection 127.0.0.1:44462 (1 connection now open)
2024-02-12T15:50:15.786+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43576 #5153 (2 connections now open)
2024-02-12T15:50:15.805+0000 I NETWORK  [conn5153] received client metadata from 127.0.0.1:43576 conn5153: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:15.810+0000 I NETWORK  [conn5153] end connection 127.0.0.1:43576 (1 connection now open)
2024-02-12T15:50:25.960+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:51694 #5154 (2 connections now open)
2024-02-12T15:50:25.979+0000 I NETWORK  [conn5154] received client metadata from 127.0.0.1:51694 conn5154: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:25.995+0000 I NETWORK  [conn5154] end connection 127.0.0.1:51694 (1 connection now open)

from overleaf.

Musicminion avatar Musicminion commented on June 4, 2024

I recently encounter this too. So I just give you a reminder. Overleaf is doing rebranding now(scheduled to release for overleaf 5.0), which means some env var called SHARELATEX_XXX now is OVERLEAF_XXX, you can check if your OVERLEAF_MONGO_URL is set correctly

from overleaf.

l4rm4nd avatar l4rm4nd commented on June 4, 2024

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)
````

from overleaf.

Musicminion avatar Musicminion commented on June 4, 2024

https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

Oh, I got.

Currently, Overleaf is doing rebranding, which means all environment var starting with SHARELATEX_XXX is now OVERLEAF_XXX, including SHARELATEX_MONGO, now it is OVERLEAF_MONGO

You need to replace these. Or you need to build your sharelatex image by your own. I am developing overleaf recently, but I use my self built image, so everthing works.

To sum up, Currently you can only use toolkit, using that docker-compose.yml file is only for developer.

Btw, you also need to init mongo as what I say above.

from overleaf.

Musicminion avatar Musicminion commented on June 4, 2024

https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

Oh, I got.

Currently, Overleaf is doing rebranding, which means all environment var starting with SHARELATEX_XXX is now OVERLEAF_XXX, including SHARELATEX_MONGO, now it is OVERLEAF_MONGO

You need to replace these. Or you need to build your sharelatex image by your own. I am developing overleaf recently, but I use my self built image, so everthing works.

To sum up, Currently you can only use toolkit, using that docker-compose.yml file is only for developer.

Btw, you also need to init mongo as what I say above.

Overleaf toolkit use dockerhub's image, which is still v4.2, but this file: https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml is used for overleaf v5.0+, so you need to use that toolkit, in order to get support and easier upgrade.

If you insist on using docker-compose.yml, you need to deal with upgrade manully, such as:

  • in overleaf 5.0, data mount path may change from sharelatex to overleaf, you need to manually migrate your data folder.
  • in overleaf 5.0, all environment SHARELATEX_XXX will be OVERLEAF_MONGO
    I don't think you have so much patience for dealing with so much chores, with toolkit, you can make it easier to upgrade.

from overleaf.

KK4BitsPerSecond avatar KK4BitsPerSecond commented on June 4, 2024

This week has been brutal at work, so I haven't had any time to mess about with this. Hopefully can make some time to work on it this weekend.

I recently encounter this too. So I just give you a reminder. Overleaf is doing rebranding now(scheduled to release for overleaf 5.0), which means some env var called SHARELATEX_XXX now is OVERLEAF_XXX, you can check if your OVERLEAF_MONGO_URL is set correctly

I didn't realize that this had happened yet. I will give it a look. I see you posted a docker compose file farther down.

Why not use toolkit? http://github.com/overleaf/toolkit

Personally, because I already run all of my other containers through Portainer.

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

Hopefully, I will have some time to try this tonight.

from overleaf.

Sciroccogti avatar Sciroccogti commented on June 4, 2024

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.

from overleaf.

nick-nsc avatar nick-nsc commented on June 4, 2024

Hi, I managed to make it work as well, but under Linux.

First of all, I built the sharelatex docker image myself using the Makefile in server-ce/ this repository (https://github.com/overleaf/overleaf/blob/main/server-ce/Makefile).
I don't know if that is necessary, I just wanted to make sure I'm running the bleeding edge version.

I also had to modify the mongo command, just as mentioned in some comments before:

Modify original docker compose (https://github.com/overleaf/overleaf/blob/main/docker-compose.yml):

* Add `command: "--replSet overleaf"` under mongo container

Then:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

Lastly:
docker-compose up -d

Hope this helps!

from overleaf.

zzttyy413841467 avatar zzttyy413841467 commented on June 4, 2024

Referring to the answers above and the methods in other places, I have changed the file to the following one so that it can run

version: '2.2'
services:
    sharelatex:
        restart: always
        # Server Pro users:
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - 80:80
        links:
            - mongo
            - redis
        stop_grace_period: 60s
        volumes:
            - ~/sharelatex_data:/var/lib/overleaf
            ########################################################################
            ####  Server Pro: Uncomment the following line to mount the docker  ####
            ####             socket, required for Sibling Containers to work    ####
            ########################################################################
            # - /var/run/docker.sock:/var/run/docker.sock
        environment:

            OVERLEAF_APP_NAME: Overleaf Community Edition

            OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
            SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
            
            # Same property, unfortunately with different names in
            # different locations
            OVERLEAF_REDIS_HOST: redis
            SHARELATEX_REDIS_HOST: redis
            REDIS_HOST: redis

            ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file'

            # Enables Thumbnail generation using ImageMagick
            ENABLE_CONVERSIONS: 'true'

            # Disables email confirmation requirement
            EMAIL_CONFIRMATION_DISABLED: 'true'

            # temporary fix for LuaLaTex compiles
            # see https://github.com/overleaf/overleaf/issues/695
            TEXMFVAR: /var/lib/overleaf/tmp/texmf-var

            ## Set for SSL via nginx-proxy
            #VIRTUAL_HOST: 103.112.212.22

            # OVERLEAF_SITE_URL: http://overleaf.example.com
            # OVERLEAF_NAV_TITLE: Overleaf Community Edition
            # OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
            # OVERLEAF_ADMIN_EMAIL: [email protected]

            # OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
            # OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'

            # OVERLEAF_EMAIL_FROM_ADDRESS: "[email protected]"

            # OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
            # OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:

            # OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
            # OVERLEAF_EMAIL_SMTP_PORT: 587
            # OVERLEAF_EMAIL_SMTP_SECURE: false
            # OVERLEAF_EMAIL_SMTP_USER:
            # OVERLEAF_EMAIL_SMTP_PASS:
            # OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
            # OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
            # OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
            # OVERLEAF_EMAIL_SMTP_LOGGER: true
            # OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"

            # ENABLE_CRON_RESOURCE_DELETION: true

            ################
            ## Server Pro ##
            ################

            # SANDBOXED_COMPILES: 'true'

            # SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
            # SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'

            # DOCKER_RUNNER: 'false'

            ## Works with test LDAP server shown at bottom of docker compose
            # OVERLEAF_LDAP_URL: 'ldap://ldap:389'
            # OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
            # OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
            # OVERLEAF_LDAP_EMAIL_ATT: 'mail'
            # OVERLEAF_LDAP_NAME_ATT: 'cn'
            # OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
            # OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'

            # OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
            # OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'


            # OVERLEAF_PROXY_LEARN: "true"`

mongo:
        restart: always
        image: mongo:5.0
        container_name: mongo
        command: "--replSet overleaf"
        expose:
            - 27017
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
    mongoinit:
        restart: "no"
        image: mongo:5.0
        depends_on:
          mongo:
            condition: service_healthy
        entrypoint:
          [
            "mongo",
            "--host",
            "mongo:27017",
            "--eval",
            'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
          ]
    redis:
        restart: always
        image: redis:6.2
        container_name: redis
        expose:
            - 6379
        volumes:
            - ~/redis_data:/data

    # ldap:
    #    restart: always
    #    image: rroemhild/test-openldap
    #    container_name: ldap
    #    expose:
    #        - 389

    # See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
    # and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
    # settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
    # but the example here can be used if you'd prefer to run everything with docker-compose

    # nginx-proxy:
    #     image: jwilder/nginx-proxy
    #     container_name: nginx-proxy
    #     ports:
    #       #- "80:80"
    #       - "443:443"
    #     volumes:
    #       - /var/run/docker.sock:/tmp/docker.sock:ro
    #       - /home/overleaf/tmp:/etc/nginx/certs

from overleaf.

5huanghuai avatar 5huanghuai commented on June 4, 2024

Referring to the answers above and the methods in other places, I have changed the file to the following one so that it can run

version: '2.2'
services:
    sharelatex:
        restart: always
        # Server Pro users:
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - 80:80
        links:
            - mongo
            - redis
        stop_grace_period: 60s
        volumes:
            - ~/sharelatex_data:/var/lib/overleaf
            ########################################################################
            ####  Server Pro: Uncomment the following line to mount the docker  ####
            ####             socket, required for Sibling Containers to work    ####
            ########################################################################
            # - /var/run/docker.sock:/var/run/docker.sock
        environment:

            OVERLEAF_APP_NAME: Overleaf Community Edition

            OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
            SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
            
            # Same property, unfortunately with different names in
            # different locations
            OVERLEAF_REDIS_HOST: redis
            SHARELATEX_REDIS_HOST: redis
            REDIS_HOST: redis

            ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file'

            # Enables Thumbnail generation using ImageMagick
            ENABLE_CONVERSIONS: 'true'

            # Disables email confirmation requirement
            EMAIL_CONFIRMATION_DISABLED: 'true'

            # temporary fix for LuaLaTex compiles
            # see https://github.com/overleaf/overleaf/issues/695
            TEXMFVAR: /var/lib/overleaf/tmp/texmf-var

            ## Set for SSL via nginx-proxy
            #VIRTUAL_HOST: 103.112.212.22

            # OVERLEAF_SITE_URL: http://overleaf.example.com
            # OVERLEAF_NAV_TITLE: Overleaf Community Edition
            # OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
            # OVERLEAF_ADMIN_EMAIL: [email protected]

            # OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
            # OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'

            # OVERLEAF_EMAIL_FROM_ADDRESS: "[email protected]"

            # OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
            # OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:

            # OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
            # OVERLEAF_EMAIL_SMTP_PORT: 587
            # OVERLEAF_EMAIL_SMTP_SECURE: false
            # OVERLEAF_EMAIL_SMTP_USER:
            # OVERLEAF_EMAIL_SMTP_PASS:
            # OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
            # OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
            # OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
            # OVERLEAF_EMAIL_SMTP_LOGGER: true
            # OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"

            # ENABLE_CRON_RESOURCE_DELETION: true

            ################
            ## Server Pro ##
            ################

            # SANDBOXED_COMPILES: 'true'

            # SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
            # SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'

            # DOCKER_RUNNER: 'false'

            ## Works with test LDAP server shown at bottom of docker compose
            # OVERLEAF_LDAP_URL: 'ldap://ldap:389'
            # OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
            # OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
            # OVERLEAF_LDAP_EMAIL_ATT: 'mail'
            # OVERLEAF_LDAP_NAME_ATT: 'cn'
            # OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
            # OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'

            # OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
            # OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'


            # OVERLEAF_PROXY_LEARN: "true"`

mongo:
        restart: always
        image: mongo:5.0
        container_name: mongo
        command: "--replSet overleaf"
        expose:
            - 27017
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
    mongoinit:
        restart: "no"
        image: mongo:5.0
        depends_on:
          mongo:
            condition: service_healthy
        entrypoint:
          [
            "mongo",
            "--host",
            "mongo:27017",
            "--eval",
            'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
          ]
    redis:
        restart: always
        image: redis:6.2
        container_name: redis
        expose:
            - 6379
        volumes:
            - ~/redis_data:/data

    # ldap:
    #    restart: always
    #    image: rroemhild/test-openldap
    #    container_name: ldap
    #    expose:
    #        - 389

    # See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
    # and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
    # settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
    # but the example here can be used if you'd prefer to run everything with docker-compose

    # nginx-proxy:
    #     image: jwilder/nginx-proxy
    #     container_name: nginx-proxy
    #     ports:
    #       #- "80:80"
    #       - "443:443"
    #     volumes:
    #       - /var/run/docker.sock:/tmp/docker.sock:ro
    #       - /home/overleaf/tmp:/etc/nginx/certs

Thank you very much. I can see some messages when I used your file, and there are some indentation errors in mongo. However, the message displayed on the web page is 502 bad gateway. The log of sharelatex is as follows. nginx is not set in the file name. Why is nginx involved in the log?

docker logs sharelatex                                                                             11:48:17
*** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...
*** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
generating random secrets
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/00_restore_site_status...
*** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
*** Running /etc/my_init.d/01_nginx_config_template.sh...
Nginx: generating config file from template
Nginx: reloading config
 * Reloading nginx configuration nginx
   ...done.
*** Running /etc/my_init.d/10_delete_old_logs.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Apr  8 03:45:46 0ed0dc228956 syslog-ng[89]: syslog-ng starting up; version='3.25.1'
*** Running /etc/my_init.d/98_check_db_access.sh...
Checking can connect to mongo and redis
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Mongodb is up.
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Redis is up.
All checks passed
*** Running /etc/my_init.d/99_run_web_migrations.sh...
Running migrations for server-ce

> migrations
> MONGO_SOCKET_TIMEOUT=0 east migrate -t server-ce

Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Nothing to migrate
Finished migrations
*** Booting runit daemon...
*** Runit started as PID 144
Apr  8 03:45:49 0ed0dc228956 cron[167]: (CRON) INFO (pidfile fd = 3)
Apr  8 03:45:49 0ed0dc228956 cron[167]: (CRON) INFO (Running @reboot jobs)
Apr  8 04:00:01 0ed0dc228956 CRON[317]: (root) CMD ( /overleaf/cron/project-history-periodic-flush.sh >> /var/log/sharelatex/cron-project-history-periodic-flush.log 2>&1)

And this is the docker-compose.yml

version: '2.2'
services:
    sharelatex:
        restart: always
        # Server Pro users:
        # image: quay.io/sharelatex/sharelatex-pro
        image: sharelatex/sharelatex
        container_name: sharelatex
        depends_on:
            mongo:
                condition: service_healthy
            redis:
                condition: service_started
        ports:
            - 80:80
        links:
            - mongo
            - redis
        stop_grace_period: 60s
        volumes:
            - ~/sharelatex_data:/var/lib/overleaf
            ########################################################################
            ####  Server Pro: Uncomment the following line to mount the docker  ####
            ####             socket, required for Sibling Containers to work    ####
            ########################################################################
            # - /var/run/docker.sock:/var/run/docker.sock
        environment:

            OVERLEAF_APP_NAME: Overleaf Community Edition

            OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
            SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
            
            # Same property, unfortunately with different names in
            # different locations
            OVERLEAF_REDIS_HOST: redis
            SHARELATEX_REDIS_HOST: redis
            REDIS_HOST: redis

            ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file'

            # Enables Thumbnail generation using ImageMagick
            ENABLE_CONVERSIONS: 'true'

            # Disables email confirmation requirement
            EMAIL_CONFIRMATION_DISABLED: 'true'

            # temporary fix for LuaLaTex compiles
            # see https://github.com/overleaf/overleaf/issues/695
            TEXMFVAR: /var/lib/overleaf/tmp/texmf-var

            ## Set for SSL via nginx-proxy
            #VIRTUAL_HOST: 103.112.212.22

            # OVERLEAF_SITE_URL: http://overleaf.example.com
            # OVERLEAF_NAV_TITLE: Overleaf Community Edition
            # OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
            # OVERLEAF_ADMIN_EMAIL: [email protected]

            # OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
            # OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'

            # OVERLEAF_EMAIL_FROM_ADDRESS: "[email protected]"

            # OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
            # OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:

            # OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
            # OVERLEAF_EMAIL_SMTP_PORT: 587
            # OVERLEAF_EMAIL_SMTP_SECURE: false
            # OVERLEAF_EMAIL_SMTP_USER:
            # OVERLEAF_EMAIL_SMTP_PASS:
            # OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
            # OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
            # OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
            # OVERLEAF_EMAIL_SMTP_LOGGER: true
            # OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"

            # ENABLE_CRON_RESOURCE_DELETION: true

            ################
            ## Server Pro ##
            ################

            # SANDBOXED_COMPILES: 'true'

            # SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
            # SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'

            # DOCKER_RUNNER: 'false'

            ## Works with test LDAP server shown at bottom of docker compose
            # OVERLEAF_LDAP_URL: 'ldap://ldap:389'
            # OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
            # OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
            # OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
            # OVERLEAF_LDAP_EMAIL_ATT: 'mail'
            # OVERLEAF_LDAP_NAME_ATT: 'cn'
            # OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
            # OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'

            # OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
            # OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'


            # OVERLEAF_PROXY_LEARN: "true"`

    mongo:
        restart: always
        image: mongo:5.0
        container_name: mongo
        command: "--replSet overleaf"
        expose:
            - 27017
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
    mongoinit:
        restart: "no"
        image: mongo:5.0
        depends_on:
          mongo:
            condition: service_healthy
        entrypoint:
          [
            "mongo",
            "--host",
            "mongo:27017",
            "--eval",
            'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
          ]
    redis:
        restart: always
        image: redis:6.2
        container_name: redis
        expose:
            - 6379
        volumes:
            - ~/redis_data:/data

    # ldap:
    #    restart: always
    #    image: rroemhild/test-openldap
    #    container_name: ldap
    #    expose:
    #        - 389

    # See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
    # and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
    # settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
    # but the example here can be used if you'd prefer to run everything with docker-compose

    # nginx-proxy:
    #     image: jwilder/nginx-proxy
    #     container_name: nginx-proxy
    #     ports:
    #       #- "80:80"
    #       - "443:443"
    #     volumes:
    #       - /var/run/docker.sock:/tmp/docker.sock:ro
    #       - /home/overleaf/tmp:/etc/nginx/certs

from overleaf.

akovy avatar akovy commented on June 4, 2024

Hello Everyone!

I think i have found the reason and solution for this when working with docker swarm mode. Below..

I am using overleaf deployed to docker swarm. I used docker-compose.yml as a template for a docker swam stack file. After overleaf team switched mongo to replSet we faced a same problem when mongo can not connect to itself and initialize primary node. As a first fix of this problem i used manual commands in running mongo container:

> cfg = {
        "_id" : "overleaf",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "localhost:27017",
                }
        ]
}
> rs.reconfig(cfg, {force : true})
overleaf:PRIMARY> cfg = {
        "_id" : "overleaf",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "mongo:27017"
                }
        ]
}
overleaf:PRIMARY>
overleaf:PRIMARY> rs.reconfig(cfg, {force : true})

After i tried to found the root cause. And it is that - once you start overleaf using docker swam mode, it appears a kind of race condition when mongod starts it tries to resolve mongo host to connect to mongo:27017 and it fails due to docker network is not ready yet and dns resolving in this network fails. So one approach is to delay starting mongod with entrypoint: "bash -c 'sleep 10 && docker-entrypoint.sh --replSet overleaf'" which is not reliable on practice.

The approach which give stable result is to use record in /etc/hosts file of the container for host mongo pointing to 127.0.0.1. As it goes that when mongod starts only /etc/hosts files resolving is working. So in this case adding:

    extra_hosts:
      - "mongo:127.0.0.1"

to compose/stack file works.

So my solution is to use mongo service definition in docker swarm stack file like this:

  mongo:
    image: mongo:4.4
    command: "--replSet overleaf"
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"
    volumes:
      - /srv/overleaf/mongo:/data/db
    networks:
      - overleaf
    extra_hosts:
      - "mongo:127.0.0.1"
    healthcheck:
      test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
      interval: 10s
      timeout: 10s
      retries: 5
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.labels.overleaf_server == true

from overleaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.