1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-19 07:18:06 +02:00

Use Docker Compose v2

By default, use Docker Compose v2, but fall back to Docker Compose v1 if
v2 is unavailable.
This commit is contained in:
Eric Mc Sween 2023-05-16 15:43:51 -04:00
parent 4353e676ee
commit 13f0e8a4db
8 changed files with 39 additions and 24 deletions

View file

@ -159,12 +159,22 @@ function print_debug_info() {
fi fi
} }
function run_docker_compose() { function docker_compose() {
exec docker-compose -p "$PROJECT_NAME" "${DOCKER_COMPOSE_FLAGS[@]}" "$@" local flags=(-p "$PROJECT_NAME" "${DOCKER_COMPOSE_FLAGS[@]}" "$@")
if docker compose version >/dev/null 2>&1; then
# Docker compose v2 is available
exec docker compose "${flags[@]}"
elif command -v docker-compose >/dev/null; then
# Fall back to docker-compose v1
exec docker-compose "${flags[@]}"
else
echo "ERROR: Could not find Docker Compose." >&2
exit 1
fi
} }
read_image_version read_image_version
read_config read_config
build_environment build_environment
print_debug_info "$@" print_debug_info "$@"
run_docker_compose "$@" docker_compose "$@"

View file

@ -113,7 +113,6 @@ function check_dependencies() {
declare -a binaries=( declare -a binaries=(
bash bash
docker docker
docker-compose
realpath realpath
perl perl
awk awk
@ -123,6 +122,16 @@ function check_dependencies() {
for binary in "${binaries[@]}"; do for binary in "${binaries[@]}"; do
check_for_binary "$binary" check_for_binary "$binary"
done done
if docker compose version > /dev/null 2>&1; then
print_point 1 "docker compose"
print_point 2 "status: present"
print_point 2 "version info: $(docker compose version)"
elif command -v docker-compose > /dev/null; then
check_for_binary docker-compose
else
add_warning "Docker Compose not found"
fi
} }
function check_docker_daemon() { function check_docker_daemon() {

4
bin/up
View file

@ -21,9 +21,9 @@ source "$TOOLKIT_ROOT/lib/shared-functions.sh"
function usage() { function usage() {
echo "Usage: bin/up [FLAGS...]" echo "Usage: bin/up [FLAGS...]"
echo "" echo ""
echo "A wrapper around 'docker-compose up'." echo "A wrapper around 'docker compose up'."
echo "" echo ""
echo "This program will pass any extra flags to docker-compose," echo "This program will pass any extra flags to docker compose,"
echo "for example: 'bin/up -d' will run in detached mode" echo "for example: 'bin/up -d' will run in detached mode"
} }

View file

@ -11,7 +11,7 @@ This directory is excluded from the git revision control system, so it will not
Note that changes to the configuration files will not be automatically applied Note that changes to the configuration files will not be automatically applied
to existing containers, even if the container is stopped and restarted (with to existing containers, even if the container is stopped and restarted (with
`bin/stop` and `bin/start`). To apply the changes, run `bin/up`, and `bin/stop` and `bin/start`). To apply the changes, run `bin/up`, and
`docker-compose` will automatically apply the configuration changes to a new `docker compose` will automatically apply the configuration changes to a new
container. (Or, run `bin/up -d`, if you prefer to not attach to the docker logs) container. (Or, run `bin/up -d`, if you prefer to not attach to the docker logs)
@ -53,6 +53,6 @@ The `config/version` file contains the version number of the docker images that
## The `docker-compose.override.yml` File ## The `docker-compose.override.yml` File
If present, the `config/docker-compose.override.yml` file will be included in the invocation to `docker-compose`. This is useful for overriding configuration specific to docker-compose. If present, the `config/docker-compose.override.yml` file will be included in the invocation to `docker compose`. This is useful for overriding configuration specific to docker compose.
See the [docker-compose documentation](https://docs.docker.com/compose/extends/#adding-and-overriding-configuration) for more details. See the [docker-compose documentation](https://docs.docker.com/compose/extends/#adding-and-overriding-configuration) for more details.

View file

@ -1,7 +1,7 @@
# Dependencies # Dependencies
This project requires a modern unix system as a base (such as Ubuntu Linux). This project requires a modern unix system as a base (such as Ubuntu Linux).
It also requires `bash`, `docker`, and `docker-compose`. It also requires `bash` and `docker`.
The `bin/doctor` script can be used to check for missing dependencies. The `bin/doctor` script can be used to check for missing dependencies.

View file

@ -1,8 +1,8 @@
# Working with Docker-Compose Services # Working with Docker Compose Services
The Overleaf Toolkit runs Overleaf inside a docker container, plus the The Overleaf Toolkit runs Overleaf inside a docker container, plus the
supporting databases (MongoDB and Redis), in their own containers. All of this supporting databases (MongoDB and Redis), in their own containers. All of this
is orchestrated with `docker-compose`. is orchestrated with `docker compose`.
Note: for legacy reasons, the main Overleaf container is called `sharelatex`, Note: for legacy reasons, the main Overleaf container is called `sharelatex`,
and is based on the `sharelatex/sharelatex` docker image. This is because the and is based on the `sharelatex/sharelatex` docker image. This is because the
@ -15,12 +15,12 @@ Overleaf naming scheme.
## The `bin/docker-compose` Wrapper ## The `bin/docker-compose` Wrapper
The `bin/docker-compose` script is a wrapper around `docker-compose`. It The `bin/docker-compose` script is a wrapper around `docker compose`. It
loads configuration from the `config/` directory, before invoking loads configuration from the `config/` directory, before invoking
`docker-compose` with whatever arguments were passed to the script. `docker compose` with whatever arguments were passed to the script.
You can treat `bin/docker-compose` as a transparent wrapper for the You can treat `bin/docker-compose` as a transparent wrapper for the
`docker-compose` program installed on your machine. `docker compose` program installed on your machine.
For example, we can check which containers are running with the following: For example, we can check which containers are running with the following:

View file

@ -18,9 +18,9 @@ Community Edition is the free version of Overleaf, while Server Pro is our enter
When you set up Overleaf using the toolkit, you will start with Community Edition, and can easily switch to Server Pro by changing just one setting. When you set up Overleaf using the toolkit, you will start with Community Edition, and can easily switch to Server Pro by changing just one setting.
## Docker, Docker-Compose, and Overleaf ## Docker, Docker Compose, and Overleaf
The toolkit uses [Docker](https://www.docker.com) and [Docker-Compose](https://docs.docker.com/compose/) to run the Overleaf software in an isolated sandbox. While we do recommend becoming familiar with both Docker and Docker-Compose, we also aim to make it as easy as possible to run Overleaf on your own computer. The toolkit uses [Docker](https://www.docker.com) and [Docker Compose](https://docs.docker.com/compose/) to run the Overleaf software in an isolated sandbox. While we do recommend becoming familiar with both Docker and Docker Compose, we also aim to make it as easy as possible to run Overleaf on your own computer.
## How do I get the Toolkit? ## How do I get the Toolkit?

View file

@ -6,10 +6,9 @@ The Overleaf Toolkit depends on the following programs:
- bash - bash
- docker - docker
- docker-compose
We recommend that you install the most recent version of docker and docker-compose that We recommend that you install the most recent version of docker that is
are available on your system. available on your system.
## Install ## Install
@ -78,7 +77,7 @@ These are the three configuration files you will interact with:
## Starting Up ## Starting Up
The Overleaf Toolkit uses `docker-compose` to manage the overleaf docker containers. The toolkit provides a set of scripts which wrap `docker-compose`, and take care of most of the details for you. The Overleaf Toolkit uses `docker compose` to manage the overleaf docker containers. The toolkit provides a set of scripts which wrap `docker compose`, and take care of most of the details for you.
Let's start the docker services: Let's start the docker services:
@ -87,7 +86,7 @@ $ bin/up
``` ```
You should see some log output from the docker containers, indicating that the containers are running. You should see some log output from the docker containers, indicating that the containers are running.
If you press `CTRL-C` at the terminal, the services will shut down. You can start them up again (without attaching to the log output) by running `bin/start`. More generally, you can run `bin/docker-compose` to control the `docker-compose` system directly, if you find that the convenience scripts don't cover your use-case. If you press `CTRL-C` at the terminal, the services will shut down. You can start them up again (without attaching to the log output) by running `bin/start`. More generally, you can run `bin/docker-compose` to control the `docker compose` system directly, if you find that the convenience scripts don't cover your use-case.
## Create the first admin account ## Create the first admin account
@ -162,9 +161,6 @@ We should see some output similar to this:
- docker - docker
- status: present - status: present
- version info: Docker version 19.03.6, build 369ce74a3c - version info: Docker version 19.03.6, build 369ce74a3c
- docker-compose
- status: present
- version info: docker-compose version 1.24.0, build 0aa59064
... ...
====== Configuration ====== ====== Configuration ======
... ...