DEV Community

Cover image for Host Sharelatex in Docker (with HTTPS)
corusm
corusm

Posted on • Edited on

Host Sharelatex in Docker (with HTTPS)

This guide is about setting up Sharelatex in a Docker container with https connection.

Install Docker

Here two examples of installing the Docker deamon. The required Packages are docker and docker-compose.

Arch Linux

yay -S docker docker-compose
Enter fullscreen mode Exit fullscreen mode

Debian / Ubuntu

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
Enter fullscreen mode Exit fullscreen mode

Enable Service

To enable the service as background task simply run

sudo systemctl enable docker
sudo systemctl start docker
Enter fullscreen mode Exit fullscreen mode

Setup Sharelatex Container

1. Create Virtual Docker Network

sudo docker network create main
Enter fullscreen mode Exit fullscreen mode

2. Configure Docker-Compose File

In the Docker-Compose File you must change several values to your custom needs.
The specific lines to change are commented.

3. Set Password for Proxy Page

You need to paste the output in line 43 of the Docker compose file.

echo $(htpasswd -nb username password) | sed -e s/\\$/\\$\\$/g
Enter fullscreen mode Exit fullscreen mode

Example:

- "traefik.http.middlewares.traefik-auth.basicauth.users=test:$$apr1$$.LOxTF4y$$/OjdUK3pSGiT/flYY42uS1"
Enter fullscreen mode Exit fullscreen mode

4. Install Latex Packages

First of all, the package manager must be installed including all Latex Packages. The package manager of Latex is called tlmgr.

Run Docker Container:
To run the Sharelatex Server enter

sudo docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Create User:
Enter your own E-Mail address to this command

docker exec sharelatex /bin/bash -c "cd /var/www/sharelatex; grunt user:create-admin --email=max@test.com"
Enter fullscreen mode Exit fullscreen mode

Install Packages:
If the Sharelatex Container is running enter following commands

sudo docker exec sharelatex wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
sudo docker exec sharelatex tar xvfz install-tl-unx.tar.gz
Enter fullscreen mode Exit fullscreen mode

Then open the Bash Console of the container

docker exec -ti sharelatex /bin/bash
Enter fullscreen mode Exit fullscreen mode
  1. Change directory: cd install-tl-XXX
  2. Change rights: chmod u+x install-tl
  3. Run ./install-tl
  4. Wait until everything is installed
  5. exit the Bash Shell of the container

Update Packages:
Now check the tlmgr (Latex Package Manager) for updates

docker exec sharelatex tlmgr update
Enter fullscreen mode Exit fullscreen mode

Important Docker Commands

Start Container

sudo docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Run without -d if you want to see the console output.

Stop Container

sudo docker-compose down
Enter fullscreen mode Exit fullscreen mode

Reload Docker-Compose File

When Container Stopped

sudo dokcer-compose up --force-recreate -d
Enter fullscreen mode Exit fullscreen mode

You're done! ❤️

Top comments (0)