From 5a646abb1242f24b749a3ba4448191428b901d96 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Fri, 18 Sep 2020 23:42:01 +0200 Subject: [PATCH] Respect COMPOSE var to make optional services easier --- abra | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/abra b/abra index 250193d..415439a 100755 --- a/abra +++ b/abra @@ -3,6 +3,10 @@ PROGRAM_NAME=$(basename "$0") ABRA_CONFIG=abra.yml +if [ -z "$COMPOSE" ]; then + COMPOSE="compose.yml" +fi + yml_pattern_exists() { PATTERN=$1 @@ -53,7 +57,7 @@ sub_help() { echo "" echo "Subcommands:" echo " cp SRC_PATH SERVICE:DEST_PATH copy files to a container" - echo " deploy [COMPOSE_FILE] let 'em rip" + echo " deploy let 'em rip" echo " logs SERVICE [ARGS] tail logs from a deployed service" echo " run SERVICE CMD run a command in the specified service's container" echo " run_args SERVICE ARGS CMD run, passing extra args to docker exec" @@ -61,6 +65,8 @@ sub_help() { echo " ... (custom commands)" echo "" echo "Make sure \$STACK_NAME is set using direnv or -a" + echo "" + echo "Runs compose.yml by default, set e.g. COMPOSE=\"compose.yml compose2.yml\" to override" } sub_secret_generate(){ @@ -112,8 +118,6 @@ sub_run(){ } sub_deploy (){ - COMPOSE=${1:-compose.yml} - echo "About to deploy:" echo " Compose: $(tput setaf 3)${PWD}/${COMPOSE}$(tput sgr0)" if [ -n "$DOMAIN" ]; then @@ -129,7 +133,8 @@ sub_deploy (){ * ) return;; esac - if docker stack deploy -c "$COMPOSE" "$STACK_NAME"; then + # shellcheck disable=SC2086 + if docker stack deploy -c ${COMPOSE/ / -c } "$STACK_NAME"; then if [ -n "$DOMAIN" ]; then echo "$(tput setaf 2)Yay! App should be available at https://${DOMAIN}$(tput sgr0)" else