diff --git a/CHANGELOG.md b/CHANGELOG.md index 157b51b..ea93d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2024-09-03 +### Added +- Add a new config option `OVERLEAF_LOG_PATH` for making [application logs](https://github.com/overleaf/overleaf/wiki/Log-files) available on the Docker host. + ## 2024-08-27 ### Added - Surface `MONGO_VERSION` from `bin/doctor` diff --git a/bin/docker-compose b/bin/docker-compose index 01a31dc..de39481 100755 --- a/bin/docker-compose +++ b/bin/docker-compose @@ -31,6 +31,9 @@ function build_environment() { if [[ $SERVER_PRO == "true" && "$SIBLING_CONTAINERS_ENABLED" == "true" ]]; then set_sibling_containers_vars fi + if [[ "${OVERLEAF_LOG_PATH:-null}" != "null" ]]; then + set_logging_vars + fi if [[ $NGINX_ENABLED == "true" ]]; then set_nginx_vars fi @@ -46,6 +49,9 @@ function build_environment() { function canonicalize_data_paths() { OVERLEAF_DATA_PATH=$(cd "$TOOLKIT_ROOT"; realpath "$OVERLEAF_DATA_PATH") + if [[ "${OVERLEAF_LOG_PATH:-null}" != "null" ]]; then + OVERLEAF_LOG_PATH=$(cd "$TOOLKIT_ROOT"; realpath "$OVERLEAF_LOG_PATH") + fi MONGO_DATA_PATH=$(cd "$TOOLKIT_ROOT"; realpath "$MONGO_DATA_PATH") REDIS_DATA_PATH=$(cd "$TOOLKIT_ROOT"; realpath "$REDIS_DATA_PATH") GIT_BRIDGE_DATA_PATH=$(cd "$TOOLKIT_ROOT"; realpath "$GIT_BRIDGE_DATA_PATH") @@ -145,6 +151,19 @@ function set_sibling_containers_vars() { export OVERLEAF_DATA_PATH } +# Set environment variables for docker-compose.logging.yml +function set_logging_vars() { + DOCKER_COMPOSE_FLAGS+=(-f "$TOOLKIT_ROOT/lib/docker-compose.logging.yml") + + if [[ $IMAGE_VERSION_MAJOR -ge 5 ]]; then + OVERLEAF_IN_CONTAINER_LOG_PATH="/var/log/overleaf" + else + OVERLEAF_IN_CONTAINER_LOG_PATH="/var/log/sharelatex" + fi + export OVERLEAF_IN_CONTAINER_LOG_PATH + export OVERLEAF_LOG_PATH +} + # Set environment variables for docker-compose.nginx.yml function set_nginx_vars() { DOCKER_COMPOSE_FLAGS+=(-f "$TOOLKIT_ROOT/lib/docker-compose.nginx.yml") diff --git a/bin/doctor b/bin/doctor index b5ea008..33f356f 100755 --- a/bin/doctor +++ b/bin/doctor @@ -210,6 +210,11 @@ function check_config_files() { print_point 2 "OVERLEAF_DATA_PATH: MISSING !" add_warning "rc file, OVERLEAF_DATA_PATH not set" fi + if [[ "${OVERLEAF_LOG_PATH:-null}" != "null" ]]; then + print_point 2 "OVERLEAF_LOG_PATH: $OVERLEAF_LOG_PATH" + else + print_point 2 "OVERLEAF_LOG_PATH: not set, keeping logs in container" + fi print_point 2 "SERVER_PRO: $SERVER_PRO" if [[ "${SERVER_PRO:-null}" == "true" ]]; then diff --git a/doc/docker-compose-to-toolkit-migration.md b/doc/docker-compose-to-toolkit-migration.md index bdbe927..d947ceb 100644 --- a/doc/docker-compose-to-toolkit-migration.md +++ b/doc/docker-compose-to-toolkit-migration.md @@ -77,6 +77,8 @@ For instructions on how to migrate `nginx`, please see [TLS Proxy for Overleaf T The location of the data volume for the `sharelatex` container will need to be set using `OVERLEAF_DATA_PATH` in the **config/overleaf.rc** file. +In case you are bind-mounting the [application logs](https://github.com/overleaf/overleaf/wiki/Log-files), you can use `OVERLEAF_LOG_PATH` to configure the host path. + ### MongoDB ### The location of the data volume for the `mongo` container will need to be set using `MONGO_DATA_PATH` in the **config/overleaf.rc** file. diff --git a/doc/overleaf-rc.md b/doc/overleaf-rc.md index cc9ccf8..40ee96f 100644 --- a/doc/overleaf-rc.md +++ b/doc/overleaf-rc.md @@ -18,10 +18,18 @@ This is useful when running multiple instances of Overleaf on one host, as each ### `OVERLEAF_DATA_PATH` -Sets the path to the directory that will be mounted into the main `sharelatex` container, and used to store compile data. This can be either a full path (beginning with a `/`), or relative to the base directory of the toolkit. +Sets the path to the directory that will be mounted into the main `sharelatex` container, and used to store project and compile data. This can be either a full path (beginning with a `/`), or relative to the base directory of the toolkit. - Default: data/sharelatex +### `OVERLEAF_LOG_PATH` + +Sets the path to the directory that will be mounted into the main `sharelatex` container, and used for making application logs available on the Docker host. This can be either a full path (beginning with a `/`), or relative to the base directory of the toolkit. + +Remove the config entry to disable the bind-mount. When not set, logs will be discarded when recreating the container. + +- Default: not set + ### `OVERLEAF_LISTEN_IP` Sets the host IP address(es) that the container will bind to. For example, if this is set to `0.0.0.0`, then the web interface will be available on any host IP address. diff --git a/lib/docker-compose.logging.yml b/lib/docker-compose.logging.yml new file mode 100644 index 0000000..64124f8 --- /dev/null +++ b/lib/docker-compose.logging.yml @@ -0,0 +1,6 @@ +--- +version: '2.2' +services: + sharelatex: + volumes: + - "${OVERLEAF_LOG_PATH}:${OVERLEAF_IN_CONTAINER_LOG_PATH}"