From: Rafael dos Santos Silva Date: Wed, 1 Feb 2017 02:41:39 +0000 (-0200) Subject: More work to make automatic build easier X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d288199f66d08272304a9434402ba17d6df28ef9;p=discourse_docker.git More work to make automatic build easier --- diff --git a/image/auto_build.rb b/image/auto_build.rb index c7d0d68..1132aa5 100644 --- a/image/auto_build.rb +++ b/image/auto_build.rb @@ -3,6 +3,15 @@ require 'pty' require 'optparse' +TODO = [:base, :discourse_test, :discourse_dev] +VERSION = "2.0.#{Time.now.strftime('%Y%m%d')}" + +images = { + base: { name: 'base', tag: "discourse/base:", squash: true }, + discourse_test: { name: 'discourse_test', tag: "discourse/discourse_test:", squash: false}, + discourse_dev: { name: 'discourse_dev', tag: "discourse/discourse_dev:", squash: false } +} + def run(command) lines = [] PTY.spawn(command) do |stdin, stdout, pid| @@ -20,9 +29,9 @@ def run(command) end def build(image) - sucess = false - lines = run("cd #{image[:name]} && docker build . --tag #{image[:tag]} #{image[:squash] ? '--squash' : ''}") - sucess = true if lines[-1] =~ 'successfully built' + lines = run("cd #{image[:name]} && docker build . --tag #{image[:tag] + VERSION} #{image[:squash] ? '#--squash' : ''}") + raise "Error building the image for #{image[:name]}: #{lines[-1]}" if lines[-1] =~ /successfully built/ + run("docker tag #{image[:tag] + VERSION} #{image[:tag]}release") end def dev_deps() @@ -30,28 +39,8 @@ def dev_deps() run("cp ../templates/redis.template.yml discourse_dev/redis.template.yml") end -options = {} -OptionParser.new do |parser| - parser.on("-i", "--image image", - "Build the image. No parameter means [base discourse discourse_test].") do |i| - options[:image] = [i.to_sym] - end -end.parse! - -DEFAULT_IMAGES = [:base, :discourse, :discourse_test, :discourse_dev, :discourse_bench] - -todo = options[:image] || DEFAULT_IMAGES -version = 'release' - -images = { - base: { name: 'base', tag: "discourse/base:#{version}", squash: true }, - discourse_test: { name: 'discourse_test', tag: "discourse/discourse_test:#{version}", squash: false}, - discourse_dev: { name: 'discourse_dev', tag: "discourse/discourse_dev:#{version}", squash: false } -} - -todo.each do |image| +TODO.each do |image| puts images[image] - bump(images[image][:name], options[:version]) if options[:version] dev_deps() if image == :discourse_dev run "(cd base && ./download_phantomjs)" if image == :base diff --git a/image/base/Dockerfile b/image/base/Dockerfile index 74d1614..6e587dd 100644 --- a/image/base/Dockerfile +++ b/image/base/Dockerfile @@ -1,5 +1,5 @@ # NAME: discourse/base -# VERSION: build +# VERSION: release FROM ubuntu:16.04 ENV PG_MAJOR 9.5 @@ -80,7 +80,7 @@ ADD install-imagemagick /tmp/install-imagemagick RUN /tmp/install-imagemagick # Validate install -RUN ruby -e "v='`convert -version`'; ['png','tiff','jpeg','freetype'].each{ |f| ((STDERR.puts('no ' + f + ' support in imagemagick')); exit(-1)) unless v.include?(f)}" +RUN ruby -e "v = %x(convert -version); ['png','tiff','jpeg','freetype'].each{ |f| ((STDERR.puts('no ' + f + ' support in imagemagick')); exit(-1)) unless v.include?(f)}" # ADD install-pngcrush /tmp/install-pngcrush diff --git a/image/base/install-imagemagick b/image/base/install-imagemagick index 80b429a..2cd110e 100755 --- a/image/base/install-imagemagick +++ b/image/base/install-imagemagick @@ -19,7 +19,7 @@ make all && make install # Build and install ImageMagick -wget -O $WDIR/ImageMagick.tar.gz "http://www.imagemagick.org/download/ImageMagick-6.9.7-0.tar.gz" +wget -O $WDIR/ImageMagick.tar.gz "http://www.imagemagick.org/download/ImageMagick-6.9.7-6.tar.gz" IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1) tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR cd $IMDIR diff --git a/image/discourse_dev/Dockerfile b/image/discourse_dev/Dockerfile index d9a1184..8e106da 100644 --- a/image/discourse_dev/Dockerfile +++ b/image/discourse_dev/Dockerfile @@ -1,5 +1,5 @@ # NAME: discourse/discourse_dev -# VERSION: build +# VERSION: release FROM discourse/base:release MAINTAINER Sam Saffron "https://twitter.com/samsaffron" diff --git a/image/discourse_test/Dockerfile b/image/discourse_test/Dockerfile index 1792736..1662ab1 100644 --- a/image/discourse_test/Dockerfile +++ b/image/discourse_test/Dockerfile @@ -1,5 +1,5 @@ # NAME: discourse/discourse_test -# VERSION: build +# VERSION: release FROM discourse/base:release MAINTAINER Sam Saffron "https://twitter.com/samsaffron"