@@ -9,9 +9,20 @@ include ${REPO_BASE_DIR}/scripts/common.Makefile
99# Running cluster
1010#
1111
12+ STACK_IS_RUNNING := $(shell docker stack ls --format '{{.Name}}' | grep -q "^$(STACK_NAME ) $$" && echo true || echo false)
13+
1214.PHONY : up
13- up : ${TEMP_COMPOSE} prune-docker-stack-configs prune-docker-stack-secrets # # Deploy rabbit
14- @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} ${STACK_NAME}
15+ up : ${TEMP_COMPOSE} \
16+ prune-docker-stack-configs \
17+ prune-docker-stack-secrets \
18+ guard-optional-bool-FORCE
19+ up : # # Deploy rabbit
20+ @if [ " $( STACK_IS_RUNNING) " = " false" ] || [ " $( FORCE) " = " true" ] ; then \
21+ docker stack deploy --detach=false --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} ${STACK_NAME} ; \
22+ else \
23+ echo " Stack $( STACK_NAME) is already running. To avoid unexpected behavior, skipping deploy" ; \
24+ echo " Check README to learn more about updates. To enforce deploy, use 'FORCE=true'" ; \
25+ fi
1526
1627up-aws : up
1728
@@ -55,6 +66,8 @@ configs/haproxy.cfg: configs/haproxy.cfg.j2 .env venv
5566# Deleting volumes (data)
5667#
5768
69+ # ## May be needed to start cluster fresh new to enforce new configuration
70+
5871CLEAN_VOLUMES_TEMP_COMPOSE := .stack.${STACK_NAME}.clean-volumes.yaml
5972CLEAN_VOLUMES_STACK_NAME := ${STACK_NAME}-clean-volumes
6073
@@ -67,20 +80,24 @@ ${CLEAN_VOLUMES_TEMP_COMPOSE}: docker-compose.clean-volumes.yaml .env
6780TIMEOUT = 2m
6881delete-volumes : ${CLEAN_VOLUMES_TEMP_COMPOSE} guard-optional-TIMEOUT guard-optional-bool-FORCE_CONFIRM
6982delete-volumes : # # Delete rabbit data volumes
70- @$(call confirm_action,Forever delete all rabbit data?,yes,${FORCE_CONFIRM})
83+ @$(call confirm_action,Forever delete all rabbit data?,deleteforever,${FORCE_CONFIRM})
84+
7185 # # avoid accumulating tasks https://github.com/moby/moby/issues/45443
7286 @docker stack rm --detach=false ${CLEAN_VOLUMES_STACK_NAME}
87+
7388 # # use --detach=false to wait until all jobs complete successfully
7489 @timeout ${TIMEOUT} \
7590 docker stack deploy --detach=false --with-registry-auth --prune --compose-file ${CLEAN_VOLUMES_TEMP_COMPOSE} ${CLEAN_VOLUMES_STACK_NAME}
91+
92+ # # cleaning up
7693 @docker stack rm ${CLEAN_VOLUMES_STACK_NAME}
7794
7895#
7996# Destroy cluster with data (to start fresh new)
8097#
8198
8299down : guard-optional-bool-FORCE_CONFIRM # # Stop rabbit cluster
83- @$(call confirm_action,Are you sure you want to stop the Rabbit cluster?,yes ,${FORCE_CONFIRM})
100+ @$(call confirm_action,Are you sure you want to stop the Rabbit cluster?,stopcluster ,${FORCE_CONFIRM})
84101 @docker stack rm ${STACK_NAME}
85102
86103destroy-cluster-with-data : down delete-volumes # # Destroy rabbit cluster with data
0 commit comments