#!/bin/bash -e while test $# -gt 0; do case "$1" in (-h|--help) cat <&2 exit 1 fi shift done for f in $*; do f=${f%.yaml} if ! test -e ${f}.yaml; then echo "ERROR: no file ${f}.yaml" 1>&2 exit 1 fi echo "... deploying ${f##*/}" for d in $(sed -n 's,^ *source: \(/.*\),\1,p' ${f}.yaml); do test -e $d || mkdir -p $d done # --with-registry-auth hands the credentials of this machine to the swarm # managers, which pass them on with every task: without them each node # pulls anonymously and runs into the pull limit of the registry docker stack deploy --with-registry-auth --compose-file ${f}.yaml ${f##*/} done