From b5819e27687abe44ff47664f852bd98c1dc37ceb Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 24 Jul 2024 16:37:19 +0000 Subject: [PATCH] Update src/dockerutils.sh --- src/dockerutils.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/dockerutils.sh b/src/dockerutils.sh index 59d395b..dc5249f 100644 --- a/src/dockerutils.sh +++ b/src/dockerutils.sh @@ -16,6 +16,7 @@ dockerutils() { echo " find_container - Find a container by name pattern. Usage: find_container " echo " find_service_node - Find the nodes where services matching a pattern are running. Usage: find_service_node " echo " exec_remote - SSH into the node where a container is running and execute a command inside it. Usage: exec_remote " + echo " deploy_stack_ng - Build, push, and deploy a stack. Usage: deploy_stack_ng " } swarm_status() { @@ -79,7 +80,7 @@ deploy_stack() { echo "Usage: deploy_stack " return 1 fi - docker stack deploy --with-registry-auth -c ~/"$1"/"$1".yml "$1" + docker stack deploy --with-registry-auth -c ~/"$1"/stack.production.yml "$1" if [ $? -ne 0 ]; then echo "Usage: Ensure the stack name is correct and the Docker Compose file exists in the specified location." return 1 @@ -142,3 +143,22 @@ exec_remote() { ssh "$container_node" "docker exec -it $container_id $2" } + +deploy_stack_ng() { + if [ -z "$1" ]; then + echo "Usage: deploy_stack_ng " + return 1 + fi + ssh "$1" "docker compose -f ~/stackname/docker-compose.staging.yml build && docker compose -f ~/stackname/docker-compose.staging.yml push && docker compose -f ~/stackname/docker-compose.production.yml build && docker compose -f ~/stackname/docker-compose.production.yml push && docker stack deploy --with-registry-auth -c ~/stackname/stack.production.yml $1" +} + +# Aliases for backward compatibility +alias check_swarm_status='swarm_status' +alias check_node_role='node_role' +alias list_docker_volumes='volumes' +alias list_docker_overlay_networks='networks' +alias dup='deploy_stack' +alias ddn='remove_stack' +alias cid='find_container' +alias service_node='find_service_node' +alias dup_ng='deploy_stack_ng'