2016-01-29 18:41:08 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# get the dockerfiles
|
|
|
|
IFS=$'\n'
|
|
|
|
files=( $(find . -iname '*Dockerfile' | sed 's|./||') )
|
|
|
|
unset IFS
|
|
|
|
|
|
|
|
# build the changed dockerfiles
|
|
|
|
for f in "${files[@]}"; do
|
|
|
|
image=${f%Dockerfile}
|
|
|
|
base=${image%%\/*}
|
|
|
|
build_dir=$(dirname $f)
|
2016-01-29 20:47:10 +01:00
|
|
|
suite=${build_dir##*\/}
|
2016-01-29 18:41:08 +01:00
|
|
|
|
2016-01-29 20:47:10 +01:00
|
|
|
if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then
|
2016-01-29 18:41:08 +01:00
|
|
|
suite=latest
|
|
|
|
fi
|
|
|
|
|
2016-05-16 04:18:36 +02:00
|
|
|
if [[ "${base}" == "sup" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2016-01-29 18:41:08 +01:00
|
|
|
(
|
|
|
|
set -x
|
|
|
|
docker build --rm --force-rm -t r.j3ss.co/${base}:${suite} ${build_dir}
|
|
|
|
)
|
|
|
|
|
|
|
|
echo " --- "
|
|
|
|
echo "Successfully built ${base}:${suite} with context ${build_dir}"
|
|
|
|
echo " --- "
|
|
|
|
|
2016-06-08 21:46:38 +02:00
|
|
|
# try push a few times because notary server sometimes returns 401 for
|
|
|
|
# absolutely no reason
|
|
|
|
n=0
|
|
|
|
until [ $n -ge 5 ]; do
|
|
|
|
docker push --disable-content-trust=false r.j3ss.co/${base}:${suite} && break
|
|
|
|
echo "Try #$n failed... sleeping for 15 seconds"
|
|
|
|
n=$[$n+1]
|
|
|
|
sleep 15
|
|
|
|
done
|
2016-01-29 20:47:10 +01:00
|
|
|
|
|
|
|
# also push the tag latest for "stable" tags
|
|
|
|
if [[ "$suite" == "stable" ]]; then
|
|
|
|
docker tag r.j3ss.co/${base}:${suite} r.j3ss.co/${base}:latest
|
2016-03-31 03:36:26 +02:00
|
|
|
docker push --disable-content-trust=false r.j3ss.co/${base}:latest
|
2016-01-29 20:47:10 +01:00
|
|
|
fi
|
2016-01-29 18:41:08 +01:00
|
|
|
done
|