Overleaf provides instructions on how to install a full Tex Live distribution which essentially involves opening a shell within the container and then using tlmgr
in order to pull the latest Tex Live distribution within the container.
The problem with that the downloaded files will only live within the container and when the service is stopped, all the downloaded files will simply vanish. Further instructions state that the user should commit the changes to the overleaf image, then perhaps re-tag the image and serve the image from a local repository. Unfortunately, that leads to large images being pulled and pushed on the local network and the inability to upgrade in the future without creating another image.
Looking at the Docker compose file, there is a more practical solution, namely, to bind-mount /usr/local/texlive
within the container to a local path on the host machine and then install Tex Live using the official instructions.
The following steps will have to be followed in order to make Tex Live available from a bind mount:
/usr/local/texlive
is now empty,Here is a snippet from the Docker compose template provided by overleaf:
version: '3.8' services: overleaf: image: sharelatex/sharelatex:latest ports: - 7643:80 volumes: - /mnt/docker/data/overleaf/default:/var/lib/overleaf - /mnt/docker/data/overleaf/texlive:/usr/local/texlive environment: OVERLEAF_APP_NAME: Overleaf Community Edition
Note that there is a new path added, namely /mnt/docker/data/overleaf/texlive
that maps into the container at /usr/local/texlive
, which is exactly where Tex Live is expected to be installed. Now, after starting the container again, check that /usr/local/texlive
is now empty. If /usr/local/texlive
is now empty, issue the following command in order to install Tex Live:
# install Tex Live cd /tmp && \ curl -L -o install-tl-unx.tar.gz https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ zcat < install-tl-unx.tar.gz | tar xf - && \ rm *.tar.gz && \ cd install-tl-* && \ perl ./install-tl --no-interaction # route symbolic links INSTALLED_VERSION=$(perl ./install-tl --version | grep -Po '(?<=version )[0-9]*') CONTAINER_VERSION=$(readlink -f /usr/local/bin/latex | grep -Po '(?<=\/usr\/local\/texlive\/)[0-9]*') [ $INSTALLED_VERSION -eq $CONTAINER_VERSION ] || ln -sf "/usr/local/texlive/$INSTALLED_VERSION" "/usr/local/texlive/$CONTAINER_VERSION"
Once the commands complete, Tex Live will have been installed within the bind-mount path and will exist outside of the image, such that committing the image is no longer necessary. The container can now be stopped and then started again in order to verify that the procedure has been successful.