diff --git a/.travis.release.images.sh b/.travis.release.images.sh index 7fddb2e..27cbbcc 100755 --- a/.travis.release.images.sh +++ b/.travis.release.images.sh @@ -7,7 +7,6 @@ IMAGES="${IMAGES:- openshift-spark openshift-spark-py36 openshift-spark-inc - openshift-spark-py36-inc }" main() { @@ -57,13 +56,22 @@ squashAndPush() { if [[ $# != 2 ]]; then echo "Usage: squashAndPush input_image output_image" && exit fi + set +e local _in=$1 local _out=$2 - echo "Squashing $_out.." - # squash last 22 layers (everything up to the base centos image) - docker-squash -f 22 -t $_out $_in + local _layers_total=$(docker history -q $_in | wc -l) + local _layers_to_keep=4 + + if [[ ! "$_layers_total" =~ ^[0-9]+$ ]] || [[ "$_layers_total" -le "$_layers_to_keep" ]] ; then + echo "error: _layers_total ('$_layers_total') is not a number or lower than or equal to $_layers_to_keep" >&2; return + fi + local _last_n=$[_layers_total - _layers_to_keep] + + echo "Squashing $_out (last $_last_n layers).." + docker-squash -f $_last_n -t $_out $_in docker push $_out + set -e } pushLatestImages() {