File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ IMAGES="${IMAGES:-
7
7
openshift-spark
8
8
openshift-spark-py36
9
9
openshift-spark-inc
10
- openshift-spark-py36-inc
11
10
} "
12
11
13
12
main () {
@@ -57,13 +56,22 @@ squashAndPush() {
57
56
if [[ $# != 2 ]]; then
58
57
echo " Usage: squashAndPush input_image output_image" && exit
59
58
fi
59
+ set +e
60
60
local _in=$1
61
61
local _out=$2
62
62
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
66
73
docker push $_out
74
+ set -e
67
75
}
68
76
69
77
pushLatestImages () {
You can’t perform that action at this time.
0 commit comments