new script docker-build to preconfigure parameters for docker build, set environment variable DOCKER_USER; fixed path in docker-update

master
Marc Wäckerlin 6 years ago
parent 15015372ea
commit adf279d43a
  1. 5
      README.md
  2. 18
      docker-build
  3. 2
      docker-update

@ -25,3 +25,8 @@ docker-update
-------------
Script to update all or some images within declared in a yaml file. Use it to update the docker image of all or some services in your already deployed docker swarm stack.
docker-build
------------
Script to be called from a directory with a Dockerfile to build the docker image. Tha name of the tag is derieved from environment variable `DOCKER_USER` and the path name. It automatically applies the options `--rm --force-rm`. As additional options, you can overwirte the image name as first parameter, and/or pass more `docker build` options.

@ -0,0 +1,18 @@
#!/bin/bash -x
if test $# -gt 0 -a "${1#-}" = "${1}"; then
name=$1
shift
else
name=$(pwd | sed 's,.*/,,')
fi
if test "$name" = "docker"; then
name=$(pwd | sed 's,/[^/]*$,,;s,.*/,,')
fi
if test "${name#*/}" = "${name}"; then
name=${DOCKER_USER:-mwaeckerlin}/${name}
fi
echo "**** building $name"
set -x
docker build $* --rm --force-rm -t ${name,,} .

@ -39,7 +39,7 @@ for f in $*; do
echo "upgrading ${name}"
IFS="
"
for param in $(sed -n '/^ *\([^:]\+\): *$/{s//'"${name}"'_\1/;h};/^ *image: */{s///;G;s/\n/ /p}' $file); do
for param in $(sed -n '/^ *\([^:]\+\): *$/{s,,'"${name}"'_\1,;h};/^ *image: */{s///;G;s/\n/ /p}' $file); do
IFS=" "
if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then
echo "....update $param: docker service update -d --image $param"

Loading…
Cancel
Save