Calculate layers to keep only when necessary
authorRafael dos Santos Silva <xfalcox@gmail.com>
Wed, 19 Oct 2016 20:40:29 +0000 (18:40 -0200)
committerRafael dos Santos Silva <xfalcox@gmail.com>
Wed, 19 Oct 2016 20:40:29 +0000 (18:40 -0200)
image/build.rb

index 30a0420acd77838065f0eafcbdc54783794f6bc7..2860293f60dca4b812709698eadace99530154c6 100644 (file)
@@ -31,7 +31,7 @@ def build(image, version)
 
   if image[:squash]
 
-    layers_to_squash = run("docker history #{img} | wc -l").first.to_i - (1 + image[:layers_to_keep])
+    layers_to_squash = run("docker history #{img} | wc -l").first.to_i - (1 + image[:layers_to_keep]) if image[:layers_to_keep] != nil
 
     if layers_to_keep != nil
       run("docker-squash -t #{image[:tag]} --verbose -f #{layers_to_squash} #{img}")