1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-25 10:18:06 +02:00
overleaf-toolkit/bin/docker-compose

58 lines
1.5 KiB
Text
Raw Permalink Normal View History

2020-06-02 14:20:23 +01:00
#! /usr/bin/env bash
set -euo pipefail
2020-06-11 11:19:35 +01:00
RC_FILE="config/overleaf.rc"
2020-06-02 14:20:23 +01:00
function __main__() {
2020-06-11 11:19:35 +01:00
# 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
2020-06-11 16:33:38 +01:00
compose_file_flags=("-f ./config/docker-compose.base.yml")
2020-06-11 11:19:35 +01:00
if [[ "$RC_REDIS_ENABLED" == "true" ]]; then
2020-06-11 16:33:38 +01:00
compose_file_flags+=("-f ./config/docker-compose.redis.yml")
2020-06-11 11:19:35 +01:00
fi
if [[ "$RC_MONGO_ENABLED" == "true" ]]; then
2020-06-11 16:33:38 +01:00
compose_file_flags+=("-f ./config/docker-compose.mongo.yml")
2020-06-11 11:19:35 +01:00
fi
# Build up the flags to pass to docker-compose
2020-06-11 11:19:35 +01:00
project_name_flag="-p ${RC_PROJECT_NAME:-overleaf}"
args="$*"
2020-06-11 15:34:18 +01:00
compose_args=" $project_name_flag ${compose_file_flags[*]} $args"
2020-06-11 11:19:35 +01:00
if [[ "${RC_DEBUG:-null}" != "null" ]]; then
2020-06-11 15:34:18 +01:00
echo ">>>>COMPOSE-ARGS>>>>"
echo "$compose_args"
echo "<<<<<<<<<<<<<<<<<<<<"
2020-06-11 11:19:35 +01:00
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
2020-06-11 15:34:18 +01:00
# shellcheck disable=SC2086
exec docker-compose $compose_args
2020-06-02 14:20:23 +01:00
}
__main__ "$@"