From cd224321df7d01357bc3e3f72a9542ad1bcbef6e Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Fri, 14 Apr 2023 20:06:29 +0200 Subject: [PATCH] add overleaf service --- README.md | 1 + ansible/max.yml | 1 + ansible/roles/overleaf/meta/main.yml | 4 + ansible/roles/overleaf/tasks/main.yml | 13 +++ .../overleaf/templates/docker-compose.yml.j2 | 107 ++++++++++++++++++ ansible/roles/overleaf/vars/main.yml | 3 + 6 files changed, 129 insertions(+) create mode 100644 ansible/roles/overleaf/meta/main.yml create mode 100644 ansible/roles/overleaf/tasks/main.yml create mode 100644 ansible/roles/overleaf/templates/docker-compose.yml.j2 create mode 100644 ansible/roles/overleaf/vars/main.yml diff --git a/README.md b/README.md index b28be77..a59720e 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ All services below are implemented using Docker: - Jitsi Meet (https://meet.jit.si) - RSS feed reader using [FreshRSS](https://miniflux.app/) - Metrics using [Prometheus](https://prometheus.io/) +- Latex editor using [Overleaf](https://www.overleaf.com/) diff --git a/ansible/max.yml b/ansible/max.yml index 2d677ff..3bf7cec 100644 --- a/ansible/max.yml +++ b/ansible/max.yml @@ -20,3 +20,4 @@ - {role: 'static', tags: 'static'} - {role: 'inbucket', tags: 'inbucket'} - {role: 'prometheus', tags: 'prometheus'} + - {role: 'overleaf', tags: 'overleaf'} diff --git a/ansible/roles/overleaf/meta/main.yml b/ansible/roles/overleaf/meta/main.yml new file mode 100644 index 0000000..6b03734 --- /dev/null +++ b/ansible/roles/overleaf/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: + - role: common + - role: docker + - role: traefik diff --git a/ansible/roles/overleaf/tasks/main.yml b/ansible/roles/overleaf/tasks/main.yml new file mode 100644 index 0000000..84256ce --- /dev/null +++ b/ansible/roles/overleaf/tasks/main.yml @@ -0,0 +1,13 @@ +- name: Create service directory + file: + path: "{{ service_dir }}" + state: directory +- name: Copy Docker Compose script + template: + src: "{{ role_path }}/templates/docker-compose.yml.j2" + dest: "{{ service_dir }}/docker-compose.yml" +- name: Start the Docker Compose + docker_compose: + project_src: "{{ service_dir }}" + pull: true + remove_orphans: true diff --git a/ansible/roles/overleaf/templates/docker-compose.yml.j2 b/ansible/roles/overleaf/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..20a3096 --- /dev/null +++ b/ansible/roles/overleaf/templates/docker-compose.yml.j2 @@ -0,0 +1,107 @@ +version: '2.2' + +networks: + traefik: + external: true + internal: + external: false + +services: + sharelatex: + restart: always + image: sharelatex/sharelatex + container_name: sharelatex + networks: + - traefik + - internal + depends_on: + mongo: + condition: service_healthy + redis: + condition: service_started + links: + - mongo + - redis + stop_grace_period: 60s + volumes: + - {{ data_dir }}/overleaf/sharelatex_data:/var/lib/sharelatex + labels: + - traefik.enable=true + - traefik.http.routers.overleaf.entrypoints=websecure + - traefik.http.routers.overleaf.rule=Host(`latex.pim.kunis.nl`) + - traefik.http.routers.overleaf.tls=true + - traefik.http.routers.overleaf.tls.certresolver=letsencrypt + - treafik.http.routers.overleaf.service=overleaf + - traefik.http.services.overleaf.loadbalancer.server.port=80 + - traefik.docker.network=traefik + environment: + SHARELATEX_APP_NAME: Overleaf Community Edition + + SHARELATEX_MONGO_URL: mongodb://mongo:27017/sharelatex + + # Same property, unfortunately with different names in + # different locations + 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/sharelatex/tmp/texmf-var + + ## Set for SSL via nginx-proxy + #VIRTUAL_HOST: 103.112.212.22 + + SHARELATEX_SITE_URL: https://latex.pim.kunis.nl + # SHARELATEX_NAV_TITLE: Our ShareLaTeX Instance + # SHARELATEX_HEADER_IMAGE_URL: http://somewhere.com/mylogo.png + SHARELATEX_ADMIN_EMAIL: pim@kunis.nl + + # SHARELATEX_LEFT_FOOTER: '[{"text": "Powered by ShareLaTeX 2016"},{"text": "Another page I want to link to can be found here"} ]' + # SHARELATEX_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]' + + SHARELATEX_EMAIL_FROM_ADDRESS: "noreply@kunis.nl" + + SHARELATEX_EMAIL_SMTP_HOST: "smtp.tweak.nl" + SHARELATEX_EMAIL_SMTP_PORT: 587 + SHARELATEX_EMAIL_SMTP_USER: "" + SHARELATEX_EMAIL_SMTP_PASS: "" + # SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: true + # SHARELATEX_EMAIL_SMTP_IGNORE_TLS: false + # SHARELATEX_EMAIL_SMTP_NAME: '127.0.0.1' + # SHARELATEX_EMAIL_SMTP_LOGGER: true + # SHARELATEX_CUSTOM_EMAIL_FOOTER: "This system is run by department x" + + mongo: + restart: always + image: mongo:4.4 + container_name: mongo + networks: + - internal + expose: + - 27017 + volumes: + - {{ data_dir }}/overleaf/mongo_data:/data/db + healthcheck: + test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet + interval: 10s + timeout: 10s + retries: 5 + + redis: + restart: always + image: redis:5 + container_name: redis + networks: + - internal + expose: + - 6379 + volumes: + - {{ data_dir }}/overleaf/redis_data:/data diff --git a/ansible/roles/overleaf/vars/main.yml b/ansible/roles/overleaf/vars/main.yml new file mode 100644 index 0000000..927a1e8 --- /dev/null +++ b/ansible/roles/overleaf/vars/main.yml @@ -0,0 +1,3 @@ +service_name: overleaf +data_dir: "{{ base_data_dir}}/{{service_name}}" +service_dir: "{{ base_service_dir}}/{{service_name}}"