From 1959166bc073d1c275939cc9ef4ca70e08d88a61 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Tue, 18 Oct 2016 21:01:46 -0200 Subject: [PATCH] Use new docker squash --- image/build.rb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/image/build.rb b/image/build.rb index 44a9fb6..8069d5b 100644 --- a/image/build.rb +++ b/image/build.rb @@ -2,9 +2,9 @@ # require 'pty' -$version = "1.3.6" +$version = "1.3.7" -$docker_squash = "https://github.com/jwilder/docker-squash/releases/download/v0.2.0/docker-squash-linux-amd64-v0.2.0.tar.gz" +$docker_squash = "https://github.com/goldmann/docker-squash/archive/master.zip" $base_image = "discourse/base:#{$version}" $image = "discourse/discourse:#{$version}" @@ -32,23 +32,26 @@ def run(command) end def ensure_docker_squash - return if File.exist?("docker-squash") - run ("wget #{$docker_squash}") - run ("tar -xzvf *.tar.gz") - run ("rm -f docker-squash-linux*") + run ("pip install --user #{$docker_squash}") end ensure_docker_squash -def build(path, tag, is_base) +def build(path, tag, layers_to_keep = nil) lines = run("cd #{path} && docker build .") img = lines[-1]["successfully built ".length..-1].strip - - run("docker save #{img} | ./docker-squash -t #{tag} -verbose #{is_base && "-from root"} | docker load") + layers_to_squash = run("docker history #{img} | wc -l").first.to_i - (1 + layers_to_keep) if layers_to_keep + if layers_to_keep != nil + puts "docker-squash -t #{tag} --verbose -f #{layers_to_squash} #{img}" + run("docker-squash -t #{tag} --verbose -f #{layers_to_squash} #{img}") + else + puts "docker-squash -t #{tag} --verbose #{img}" + run("docker-squash -t #{tag} --verbose #{img}") + end end run "(cd base && ./download_phantomjs)" -build("base",$base_image,true) -build("discourse",$image,false) -build("discourse_test",$test,false) +build("base",$base_image) +build("discourse",$image,1) +build("discourse_test",$test,2) -- 2.25.1