Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for existing and new docker compose syntax #171

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions manage
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ if [[ "$OSTYPE" == "msys" ]]; then
terminalEmu="winpty"
fi

# ========================================================================================================
# Dynamically detect the version of docker compose and adjust the '--log-level' syntax appropriately.
# --------------------------------------------------------------------------------------------------------
# Default to using the existing syntax
dockerCompose="docker-compose --log-level ERROR"
dockerComposeVersion=$(docker-compose version --short | sed 's~v~~;s~-.*~~')
dockerComposeVersion=${dockerComposeVersion%.*}
if [[ $(awk "BEGIN {print (${dockerComposeVersion} >= 2.0) ? \"true\" : \"false\" }") == "true" ]]; then
# Use the new syntax when version 2.0.0 or greater is detected.
dockerCompose="docker --log-level error compose"
fi
# ========================================================================================================

# =================================================================================================================
# Usage:
# -----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -288,8 +301,8 @@ function runCliCommand() {
cliUsage
fi

cmd="${terminalEmu} docker --log-level error \
compose run "
cmd="${terminalEmu} ${dockerCompose} \
run "

if [ -z "${VOLUMES}" ] && [ -d "${DEFAULT_CLI_SCRIPT_DIR}" ] ; then
VOLUMES=$(realpath ${DEFAULT_CLI_SCRIPT_DIR})
Expand All @@ -305,7 +318,7 @@ function runCliCommand() {
# When running on Windows, you need to prefix the path with an extra '/'
path="/${path}"
fi
cmd+=" -v='${path}:/home/indy/${mountPoint}:Z'"
cmd+=" -v '${path}:/home/indy/${mountPoint}:Z'"
done
fi

Expand Down Expand Up @@ -341,8 +354,8 @@ function logs() {
log_args=()
(( no_tail != 1 )) && log_args+=( '-f' )
if [ ! -z "${TAIL_LOGS}" ] || [ ! -z "${_force}" ]; then
docker --log-level error \
compose logs \
${dockerCompose} \
logs \
"${log_args[@]}" "$@"
fi
)
Expand Down Expand Up @@ -644,8 +657,8 @@ case "${COMMAND}" in
start|up)
initEnv "$@"
install_taa
docker --log-level error \
compose up \
${dockerCompose} \
up \
-d webserver node1 node2 node3 node4
wait_for_ledger
logs
Expand All @@ -654,8 +667,8 @@ case "${COMMAND}" in
start-combined)
initEnv "$@"
install_taa
docker --log-level error \
compose up \
${dockerCompose} \
up \
-d webserver nodes
wait_for_ledger
logs
Expand All @@ -665,16 +678,16 @@ case "${COMMAND}" in
if [ -z "$LEDGER_SEED" ]; then
export ANONYMOUS=1
fi
docker --log-level error \
compose up \
${dockerCompose} \
up \
-d webserver
wait_for_ledger
logs webserver
;;
synctest)
initEnv "$@"
docker --log-level error \
compose up \
${dockerCompose} \
up \
-d synctest node1 node2 node3 node4
logs -f synctest
;;
Expand All @@ -690,8 +703,8 @@ case "${COMMAND}" in
;;
stop)
initEnv "$@"
docker --log-level error \
compose stop
${dockerCompose} \
stop
remove_taa
;;
down|rm)
Expand Down