Initial commit

This commit is contained in:
Markus Thielker 2025-04-07 11:13:30 +02:00
commit e662a0172c
6 changed files with 141 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
# IntelliJ
/.idea
overleaf.iml

38
README.md Normal file
View file

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

79
docker-compose.yaml Normal file
View file

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

7
hnu-logo-white.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.3 KiB

7
hnu-logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.3 KiB

6
setup-replica-set.sh Normal file
View file

@ -0,0 +1,6 @@
docker exec -it markus_latex_mongo mongosh --eval "rs.initiate({
_id: \"overleaf\",
members: [
{_id: 0, host: \"mongo:27017\"},
]
})"