File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ main() {
18
18
loginDockerIo
19
19
pushLatestImages " docker.io"
20
20
loginQuayIo
21
- pushLatestImages " quay.io"
21
+ pushLatestImages " quay.io"
22
22
elif [[ " ${TRAVIS_TAG} " =~ ^[0-9]+\. [0-9]+\. [0-9]+-[0-9]+$ ]]; then
23
23
echo " Squashing and pushing the '${TRAVIS_TAG} ' images to docker.io and quay.io"
24
24
buildImages
@@ -60,9 +60,16 @@ squashAndPush() {
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 ; exit
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
67
74
}
68
75
You can’t perform that action at this time.
0 commit comments