#
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}"
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)