new names and new script
This commit is contained in:
		
							
								
								
									
										56
									
								
								docker-deploy
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										56
									
								
								docker-deploy
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
#!/bin/bash -e
 | 
			
		||||
 | 
			
		||||
while test $# -gt 0; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
	(-h|--help) cat <<EOF
 | 
			
		||||
$0 [OPTIONS] FILES…
 | 
			
		||||
 | 
			
		||||
OPTIONS
 | 
			
		||||
 | 
			
		||||
  -h, --help           show this help
 | 
			
		||||
 | 
			
		||||
FILES…
 | 
			
		||||
 | 
			
		||||
  List of stack names or yaml files to deploy. There must be yaml
 | 
			
		||||
  files with the same name. The extension .yaml may be given or not.
 | 
			
		||||
 | 
			
		||||
DESCRIPTION
 | 
			
		||||
 | 
			
		||||
  Deploys stack from yaml files. The stack name is identical to the
 | 
			
		||||
  file name, but wihout path and without .yaml extendsion.
 | 
			
		||||
 | 
			
		||||
EXAMPLS
 | 
			
		||||
 | 
			
		||||
  The following calls ado the same and deploy a local yaml file:
 | 
			
		||||
 | 
			
		||||
    $0 yaml-file-name
 | 
			
		||||
    $0 yaml-file-name.yaml
 | 
			
		||||
    $0 ./yaml-file-name.yaml
 | 
			
		||||
 | 
			
		||||
  Deploy three files from three sources:
 | 
			
		||||
 | 
			
		||||
    $0 /path/to/file1/first.yaml /path/to/file2/second.yaml third
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
		    exit;;
 | 
			
		||||
	(*) break;;
 | 
			
		||||
    esac
 | 
			
		||||
    if test $# -lt 1; then
 | 
			
		||||
	echo "error: missing argument, try $0 --help" 1>&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: *//p' ${f}.yaml); do
 | 
			
		||||
        test -e $d || mkdir -p $d
 | 
			
		||||
    done
 | 
			
		||||
    docker stack deploy --compose-file ${f}.yaml ${##*/f}
 | 
			
		||||
done
 | 
			
		||||
		Reference in New Issue
	
	Block a user