If you are a student or an academic in a science field you have probably heard about LaTeX. It is a software for typesetting documents. To say it in another way, a fancy Micro$oft Word.
Well, it is awesome because it is free software and an amazing standardization platform, but it is not that easy to use.
Some platforms have developed around it, to be specific, I am talking about overleaf, a collaborative cloud-based text editor. I have used in cases when live collaboration is needed, the problem is pricing, even if you are a student it is kinda expensive.
Well, thanks to overleaf’s free software nature you can actually host it yourself and get most of the priced features for “free”. The tricky part is making a full install and not just the basic official one, this will be explained in this post.
Requirements
To host a service like Overleaf you requiere a Linux server where you can run it, the only requirement for an official installation is to have docker installed.
To install docker you can follow a lot of guides and I hope you have some ideas about reverse proxy and that kind of things in case you want to have it publicly available.
Basic overleaf install
For the basic Overleaf install you can follow the official steps which are:
1. Clone the git-repo to your machine
git clone https://github.com/overleaf/toolkit.git ./overleaf
cd overleaf
2. Initialize the configuration
./bin/init
3. Configure the variables
Check the files config/overleaf.rc
and config/variables.env
according to your needs.
In case of an external server you may want to change the listening ip and listening port like:
OVERLEAF_LISTEN_IP=0.0.0.0
OVERLEAF_PORT=8080
4. Start the container
./bin/up
Following this steps will present you a working overleaf interface in http://your-ip-here:8080/launchpad
ready to be configured, you may be have a reverse proxy so YMMV.
Full LaTeX install
Now having a working Overleaf instance we need to add all the LaTeX goodies in order to be able to compile complex files. To do this, we need to create a custom image.
1. Create a Containerfile
We need to base our image on the already created ShareLaTeX public image. We just need to check in order to use the same tag. I am using 5.0.3
.
We also need to install the latest Tex Live with all the extensions.
To finish we need to make a symlink because the original image is set to work with a 2023 texlive installation so we make this little trick to make it work with the 2024 one.
We end with the following Containerfile:
FROM docker.io/sharelatex/sharelatex:5.0.3
# Download complete and updated texlive
RUN wget https://mirror.clientvps.com/CTAN/systems/texlive/tlnet/install-tl-unx.tar.gz && \
tar -xf install-tl-unx.tar.gz && \
rm install-tl-unx.tar.gz && \
cd install-tl-* && \
perl install-tl --no-interaction
# Make the link for texlive
RUN rm -rf /usr/local/texlive/2023 && \
ln -sf /usr/local/texlive/2024 /usr/local/texlive/2023
2. Build the container image
In order to build the full image, we run the following command. This may take a while, so be patient.
docker build -t sharelatex/sharelatex:with-texlive-full -f Containerfile .
3. Change docker-compose
The Overleaf toolkit has a custom script for using docker-compose. In order to change the tag of the used Overleaf image, we need to create config/docker-compose.override.yml
containing:
---
version: '2.2'
services:
sharelatex:
image: sharelatex/sharelatex:with-texlive-full
4. Recreate the container
With the configuration made, we just need to delete the old container and recreate it with our full image.
./bin/stop && ./bin/docker-compose rm -f sharelatex && ./bin/up -d
Conclusion
Configuring Overleaf is not that hard and it is a good investment instead of paying Overleaf for their services. Remember this is all thanks to free software. :D
Notes
Keep in mind that the custom image process needs to be done after each upgrade.