Skip to content

Commit 8f9c127

Browse files
committed
Instead of using fixed number of layers we want to squash, squash all of them up to the first four.
1 parent 3c6ac3b commit 8f9c127

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.travis.release.images.sh

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ IMAGES="${IMAGES:-
77
openshift-spark
88
openshift-spark-py36
99
openshift-spark-inc
10-
openshift-spark-py36-inc
1110
}"
1211

1312
main() {
@@ -57,13 +56,22 @@ squashAndPush() {
5756
if [[ $# != 2 ]]; then
5857
echo "Usage: squashAndPush input_image output_image" && exit
5958
fi
59+
set +e
6060
local _in=$1
6161
local _out=$2
6262

63-
echo "Squashing $_out.."
64-
# squash last 22 layers (everything up to the base centos image)
65-
docker-squash -f 22 -t $_out $_in
63+
local _layers_total=$(docker history -q $_in | wc -l)
64+
local _layers_to_keep=4
65+
66+
if [[ ! "$_layers_total" =~ ^[0-9]+$ ]] || [[ "$_layers_total" -le "$_layers_to_keep" ]] ; then
67+
echo "error: _layers_total ('$_layers_total') is not a number or lower than or equal to $_layers_to_keep" >&2; return
68+
fi
69+
local _last_n=$[_layers_total - _layers_to_keep]
70+
71+
echo "Squashing $_out (last $_last_n layers).."
72+
docker-squash -f $_last_n -t $_out $_in
6673
docker push $_out
74+
set -e
6775
}
6876

6977
pushLatestImages() {

0 commit comments

Comments
 (0)