Skip to content

Commit

Permalink
Instead of using fixed number of layers we want to squash, squash all…
Browse files Browse the repository at this point in the history
… of them up to the first four.
  • Loading branch information
jkremser committed May 30, 2019
1 parent 3c6ac3b commit 8f9c127
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .travis.release.images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ IMAGES="${IMAGES:-
openshift-spark
openshift-spark-py36
openshift-spark-inc
openshift-spark-py36-inc
}"

main() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8f9c127

Please sign in to comment.