Update src/dockerutils.sh
This commit is contained in:
parent
95aba9a28e
commit
b5819e2768
|
@ -16,6 +16,7 @@ dockerutils() {
|
|||
echo " find_container - Find a container by name pattern. Usage: find_container <container-name-pattern>"
|
||||
echo " find_service_node - Find the nodes where services matching a pattern are running. Usage: find_service_node <service-name-pattern>"
|
||||
echo " exec_remote - SSH into the node where a container is running and execute a command inside it. Usage: exec_remote <container-name-pattern> <command>"
|
||||
echo " deploy_stack_ng - Build, push, and deploy a stack. Usage: deploy_stack_ng <stack-name>"
|
||||
}
|
||||
|
||||
swarm_status() {
|
||||
|
@ -79,7 +80,7 @@ deploy_stack() {
|
|||
echo "Usage: deploy_stack <stack-name>"
|
||||
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 <stack-name>"
|
||||
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'
|
||||
|
|
Loading…
Reference in New Issue