new script docker-build to preconfigure parameters for docker build, set environment variable DOCKER_USER; fixed path in docker-update
This commit is contained in:
@@ -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.
|
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.
|
||||||
|
18
docker-build
Executable file
18
docker-build
Executable file
@@ -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}"
|
echo "upgrading ${name}"
|
||||||
IFS="
|
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=" "
|
IFS=" "
|
||||||
if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then
|
if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then
|
||||||
echo "....update $param: docker service update -d --image $param"
|
echo "....update $param: docker service update -d --image $param"
|
||||||
|
Reference in New Issue
Block a user