commit e662a0172c21a5d06f0359af0b88d94cc5176b50 Author: Markus Thielker Date: Mon Apr 7 11:13:30 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77ae6e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +# IntelliJ +/.idea +overleaf.iml diff --git a/README.md b/README.md new file mode 100644 index 0000000..2b8f869 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Overleaf Setup + +## Getting started + +1. Upload the docker-compose.yaml to the server directory. +2. Start the MongoDB alone using `docker compose up -d mongo` and wait about 15 seconds for it to start. +3. Execute the script [setup-replica-set.sh](setup-replica-set.sh) to create the ReplicaSet, required by the sharedlatex + container +4. Now start all other containers using `docker compose up -d` + +## Docker Overview + +1. What does the Compose stack contain? +``` + The compose stack consists of three containers. + The sharelatex container is the actual Overleaf application, + containing the frontend and the backend of the application. + It requires two different datasources, a MongoDB and a Redis. +``` + +2. How to access the application? +``` + The docker-compose.yaml file in this repository is setup to + automatically connect to a running [Treafik](https://traefik.io) + instance. If a different reverse proxy is used, the traefik labels + can be removed and the required configuration has to be added. +``` + +3. Why setting up a ReplicaSet with a single MongoDB instance? +``` + The Overleaf application depends on using transactions. Transactions are + only supported by MongoDB if a Replica Set is active. +``` + +4. Where is the data stored? +``` + All relevant data from each container is bound to a Docker volume each. +``` diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9248dcf --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,79 @@ +services: + + latex: + restart: unless-stopped + image: sharelatex/sharelatex:5.3 + container_name: markus_latex + depends_on: + mongo: + condition: service_started + redis: + condition: service_started + stop_grace_period: 60s + volumes: + - latex-data:/var/lib/overleaf + labels: + - "traefik.enable=true" + - "traefik.http.routers.dev-thielker-latex.rule=Host(latex.thielker.dev)" + - "traefik.http.routers.dev-thielker-latex.entrypoints=web, websecure" + - "traefik.http.routers.dev-thielker-latex.tls=true" + - "traefik.http.routers.dev-thielker-latex.tls.certresolver=lets-encrypt" + networks: + - web + - internal + environment: + OVERLEAF_APP_NAME: HNU - Overleaf + OVERLEAF_MONGO_URL: mongodb://mongo/latex + OVERLEAF_REDIS_HOST: redis + REDIS_HOST: redis + + ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file' + ENABLE_CONVERSIONS: 'true' + EMAIL_CONFIRMATION_DISABLED: 'true' + + OVERLEAF_SITE_URL: https://latex.thielker.dev + OVERLEAF_NAV_TITLE: Overleaf + OVERLEAF_HEADER_IMAGE_URL: https://git.thielker.dev/markus/overleaf/hnu-logo-white.svg + + + mongo: + container_name: markus_latex_mongo + image: mongo:8.0.6 + restart: unless-stopped + environment: + MONGO_INITDB_DATABASE: latex + volumes: + - mongo-data:/data/db + networks: + - internal + extra_hosts: + - mongo:127.0.0.1 + healthcheck: + test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet + interval: 30s + timeout: 10s + start_period: 0s + start_interval: 1s + retries: 30 + + + redis: + restart: always + image: redis:6.2 + container_name: markus_latex_redis + networks: + - internal + volumes: + - redis-data:/data + + +volumes: + redis-data: + mongo-data: + latex-data: + + +networks: + internal: + web: + external: true diff --git a/hnu-logo-white.svg b/hnu-logo-white.svg new file mode 100644 index 0000000..f62dbac --- /dev/null +++ b/hnu-logo-white.svg @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/hnu-logo.svg b/hnu-logo.svg new file mode 100644 index 0000000..8575334 --- /dev/null +++ b/hnu-logo.svg @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/setup-replica-set.sh b/setup-replica-set.sh new file mode 100644 index 0000000..7406526 --- /dev/null +++ b/setup-replica-set.sh @@ -0,0 +1,6 @@ +docker exec -it markus_latex_mongo mongosh --eval "rs.initiate({ + _id: \"overleaf\", + members: [ + {_id: 0, host: \"mongo:27017\"}, + ] +})"