1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-25 02:08:06 +02:00
overleaf-toolkit/bin/docker-compose
2020-06-12 09:19:33 +01:00

57 lines
1.5 KiB
Bash
Executable file

#! /usr/bin/env bash
set -euo pipefail
RC_FILE="config/overleaf.rc"
function __main__() {
# Load vars from the rc file, prefixed with 'RC_ '
# shellcheck disable=SC1090
source <(
grep -v '^#' "$RC_FILE" | # remove lines starting with '#'
grep . | # remove blank lines
grep -E '^[A-Z_]+=' | # filter down to variable assignments
awk '{print "RC_" $0}' # prefix with 'RC_'
)
if [[ "${RC_DEBUG:-null}" != "null" ]]; then
echo ">>>>VARS>>>>"
echo "$(set -o posix; set | grep ^RC_)"
echo "<<<<<<<<<<<<"
fi
# Select which docker-compose files to load
compose_file_flags=("-f ./config/docker-compose.base.yml")
if [[ "$RC_REDIS_ENABLED" == "true" ]]; then
compose_file_flags+=("-f ./config/docker-compose.redis.yml")
fi
if [[ "$RC_MONGO_ENABLED" == "true" ]]; then
compose_file_flags+=("-f ./config/docker-compose.mongo.yml")
fi
# Build up the flags to pass to docker-compose
project_name_flag="-p ${RC_PROJECT_NAME:-overleaf}"
args="$*"
compose_args=" $project_name_flag ${compose_file_flags[*]} $args"
if [[ "${RC_DEBUG:-null}" != "null" ]]; then
echo ">>>>COMPOSE-ARGS>>>>"
echo "$compose_args"
echo "<<<<<<<<<<<<<<<<<<<<"
fi
# Export vars for use in docker-compose files
export RC_IMAGE
export RC_SHARELATEX_DATA_PATH
export RC_DOCKER_SOCKET_PATH
export RC_MONGO_IMAGE
export RC_MONGO_DATA_PATH
export RC_REDIS_IMAGE
export RC_REDIS_DATA_PATH
# shellcheck disable=SC2086
exec docker-compose $compose_args
}
__main__ "$@"