Respect COMPOSE var to make optional services easier

This commit is contained in:
3wc 2020-09-18 23:42:01 +02:00
parent 4658e3484c
commit 5a646abb12
1 changed files with 9 additions and 4 deletions

13
abra
View File

@ -3,6 +3,10 @@
PROGRAM_NAME=$(basename "$0") PROGRAM_NAME=$(basename "$0")
ABRA_CONFIG=abra.yml ABRA_CONFIG=abra.yml
if [ -z "$COMPOSE" ]; then
COMPOSE="compose.yml"
fi
yml_pattern_exists() { yml_pattern_exists() {
PATTERN=$1 PATTERN=$1
@ -53,7 +57,7 @@ sub_help() {
echo "" echo ""
echo "Subcommands:" echo "Subcommands:"
echo " cp SRC_PATH SERVICE:DEST_PATH copy files to a container" 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 " logs SERVICE [ARGS] tail logs from a deployed service"
echo " run SERVICE CMD run a command in the specified service's container" 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" echo " run_args SERVICE ARGS CMD run, passing extra args to docker exec"
@ -61,6 +65,8 @@ sub_help() {
echo " ... (custom commands)" echo " ... (custom commands)"
echo "" echo ""
echo "Make sure \$STACK_NAME is set using direnv or -a" 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(){ sub_secret_generate(){
@ -112,8 +118,6 @@ sub_run(){
} }
sub_deploy (){ sub_deploy (){
COMPOSE=${1:-compose.yml}
echo "About to deploy:" echo "About to deploy:"
echo " Compose: $(tput setaf 3)${PWD}/${COMPOSE}$(tput sgr0)" echo " Compose: $(tput setaf 3)${PWD}/${COMPOSE}$(tput sgr0)"
if [ -n "$DOMAIN" ]; then if [ -n "$DOMAIN" ]; then
@ -129,7 +133,8 @@ sub_deploy (){
* ) return;; * ) return;;
esac 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 if [ -n "$DOMAIN" ]; then
echo "$(tput setaf 2)Yay! App should be available at https://${DOMAIN}$(tput sgr0)" echo "$(tput setaf 2)Yay! App should be available at https://${DOMAIN}$(tput sgr0)"
else else