--- /dev/null
+# simple build file to be used locally by Sam
+#
+require 'pty'
+require 'optparse'
+
+def run(command)
+ lines = []
+ PTY.spawn(command) do |stdin, stdout, pid|
+ begin
+ stdin.each do |line|
+ lines << line
+ puts line
+ end
+ rescue Errno::EIO
+ # we are done
+ end
+ end
+
+ lines
+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'
+end
+
+def dev_deps()
+ run("sed -e 's/\(db_name: discourse\)/\1_development/' ../templates/postgres.template.yml > discourse_dev/postgres.template.yml")
+ 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|
+ 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
+
+ build(images[image])
+end
# NAME: discourse/base
-# VERSION: 1.3.10
+# VERSION: build
FROM ubuntu:16.04
ENV PG_MAJOR 9.5
ADD cron /etc/service/cron/run
ADD rsyslog /etc/service/rsyslog/run
ADD cron.d_anacron /etc/cron.d/anacron
+
+
+# Discourse specific bits
+RUN useradd discourse -s /bin/bash -m -U &&\
+ mkdir -p /var/www &&\
+ cd /var/www &&\
+ git clone https://github.com/discourse/discourse.git &&\
+ cd discourse &&\
+ git remote set-branches --add origin tests-passed &&\
+ chown -R discourse:discourse /var/www/discourse &&\
+ cd /var/www/discourse &&\
+ sudo -u discourse bundle install --deployment \
+ --without test --without development &&\
+ find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
+++ /dev/null
-# NAME: discourse/discourse
-# VERSION: 1.3.10
-FROM discourse/base:1.3.10
-
-MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
-
-# Discourse specific bits
-RUN useradd discourse -s /bin/bash -m -U &&\
- mkdir -p /var/www &&\
- cd /var/www &&\
- git clone https://github.com/discourse/discourse.git &&\
- cd discourse &&\
- git remote set-branches --add origin tests-passed &&\
- chown -R discourse:discourse /var/www/discourse &&\
- cd /var/www/discourse &&\
- sudo -u discourse bundle install --deployment \
- --without test --without development &&\
- find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
# NAME: discourse/discourse_dev
-# VERSION: 1.3.10
-FROM discourse/base:1.3.10
+# VERSION: build
+FROM discourse/base:release
MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
RUN apt-get update && apt-get install -y libsqlite3-dev \
&& gem install mailcatcher && rm -rf /var/lib/apt/lists/*
-# Create discourse user and /var/www location for both
-# discourse and dev images.
-RUN useradd discourse -s /bin/bash -m -U &&\
- mkdir -p /var/www
+# Remove the code added on base image
+RUN rm -rf /var/www/*
# Give discourse user no-passwd sudo permissions (for bundle install)
ADD sudoers.discourse /etc/sudoers.d/discourse
# NAME: discourse/discourse_test
-# VERSION: 1.3.10
-FROM discourse/discourse:1.3.10
+# VERSION: build
+FROM discourse/base:release
MAINTAINER Sam Saffron "https://twitter.com/samsaffron"