From: Rafael dos Santos Silva Date: Wed, 19 Oct 2016 20:40:29 +0000 (-0200) Subject: Calculate layers to keep only when necessary X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=25aed7eae4087b0a2e0e89fcdaa4052f95ba5adb;p=discourse_docker.git Calculate layers to keep only when necessary --- diff --git a/image/build.rb b/image/build.rb index 30a0420..2860293 100644 --- a/image/build.rb +++ b/image/build.rb @@ -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}")