# Local Overleaf ## Hardware Requirements * 2 CPU cores + 3GB RAM memory for basic operations (~5 concurrent users); * 1 CPU core + 1GB RAM memory should be added to the minimal install for every 5-10 concurrent users. > LaTeX is a single-threaded program. As a result, the faster the single-core performance of your CPU, the quicker the document compilation will be. Additional cores will only be beneficial if you're compiling multiple documents simultaneously and have more documents than available CPU cores. ## Install script Set up and administer Overleaf Community Edition. ``` git clone https://github.com/overleaf/toolkit.git ./overleaf-toolkit cd ./overleaf-toolkit # create our local configuration bin/init #start the docker services bin/up # start them up again (without attaching to the log output) bin/start ``` On the http://localhost/project page, you will see a button prompting you to create your first project. ### Convenience Helpers * bin/up: shortcut for bin/docker-compose up * bin/start: shortcut for bin/docker-compose start * bin/stop: shortcut for bin/docker-compose stop * bin/shell: starts a shell inside the main container * bin/docker-compose: a wrapper around docker compose ### Architecture * /etc/service/: initialisation files for the microservices * /etc/overleaf/settings.js: unified settings file for the microservices * /var/log/overleaf/: logs for each microservice * /var/www/overleaf/: code for the various microservices * /var/lib/overleaf/: the mount-point for persistent data (corresponds to the directory indicated by OVERLEAF_DATA_PATH on the host) ### Check the logs ``` # look at the logs inside the container bin/logs -f web # multiple micro-services at once bin/logs -f filestore docstore web clsi ``` ### debugging your installation For any dependencies missing, local configuration, or any problems encountered: ``` bin/doctor ``` > Quick-Start Guide for [Overleaf Toolkit](https://github.com/overleaf/toolkit/blob/master/doc/quick-start-guide.md). ## Overleaf Docker Image Using Docker to run Overleaf locally is the most efficient and easiest way, as Docker ensures that all dependencies and configurations are handled automatically. You can spin up Overleaf with minimal setup. First, clone the [repo]: ``` git clone https://github.com/overleaf/overleaf ``` The Base image contains the basic dependencies like wget, plus texlive (heavy set of dependencies), and the sharelatex/sharelatex image extends the base image and adds the actual Overleaf code and services. To build the two dockerfiles [Dockerfile-base](https://github.com/overleaf/overleaf/blob/main/server-ce/Dockerfile-base) and [Dockerfile](https://github.com/overleaf/overleaf/blob/main/server-ce/Dockerfile): ``` cd overleaf/server-ce # Dockerfile-base to build sharelatex/sharelatex-base image make build-base # Dockerfile to build the `sharelatex/sharelatex` (or "community") image make build-community ``` The [Phusion base-image](https://github.com/phusion/baseimage-docker) (which is extended by our `base` image) is used instead of the stock ubuntu image. Ubuntu is not intended to be run inside Docker. Its init system, Upstart, expects to run on physical or virtual hardware, not within a Docker container. However, containers are designed to run minimal systems, not full ones. Configuring a minimal system for container use involves navigating numerous tricky edge cases that can be difficult to manage without in-depth knowledge of the Unix system model. This can lead to various unexpected issues. Phusion base-image provides us with a VM-like container in which to run the Overleaf services. Baseimage uses the `runit` service manager to manage services, and we add our init-scripts from the `server-ce/runit` folder. > Further documentation on releases, features and other configuration elements in the [wiki](https://github.com/overleaf/overleaf/wiki). ### Storing Data & Backups The directory you mount at /var/lib/sharelatex is where Overleaf will store data such as images, this is what you will need to backup, in addition to mongodb & redis. The example mounts it from ~/sharelatex_datat but it can be anywhere accessible from the docker image. ### Using a compose file It is recommended to the [docker-compose.yml file](https://github.com/overleaf/overleaf/blob/old-master/docker-compose.yml) to get up and running. In addition to installing and starting Overleaf it also setup redis and mongodb, with an option of HTTPS via nginx proxy. The docker compose file also allows for a nice interface for passing environment variables to Overleaf.