Let's try busting the cache
[discourse_docker.git] / image / auto_build.rb
CommitLineData
67446876
RSS
1# simple build file to be used locally by Sam
2#
3require 'pty'
4require 'optparse'
5
d288199f
RSS
6TODO = [:base, :discourse_test, :discourse_dev]
7VERSION = "2.0.#{Time.now.strftime('%Y%m%d')}"
8
9images = {
10 base: { name: 'base', tag: "discourse/base:", squash: true },
11 discourse_test: { name: 'discourse_test', tag: "discourse/discourse_test:", squash: false},
12 discourse_dev: { name: 'discourse_dev', tag: "discourse/discourse_dev:", squash: false }
13}
14
67446876
RSS
15def run(command)
16 lines = []
17 PTY.spawn(command) do |stdin, stdout, pid|
18 begin
19 stdin.each do |line|
20 lines << line
21 puts line
22 end
23 rescue Errno::EIO
24 # we are done
25 end
26 end
27
28 lines
29end
30
31def build(image)
7ead2337 32 lines = run("cd #{image[:name]} && docker build . --no-cache --tag #{image[:tag] + VERSION} #{image[:squash] ? '#--squash' : ''}")
d288199f
RSS
33 raise "Error building the image for #{image[:name]}: #{lines[-1]}" if lines[-1] =~ /successfully built/
34 run("docker tag #{image[:tag] + VERSION} #{image[:tag]}release")
67446876
RSS
35end
36
37def dev_deps()
38 run("sed -e 's/\(db_name: discourse\)/\1_development/' ../templates/postgres.template.yml > discourse_dev/postgres.template.yml")
39 run("cp ../templates/redis.template.yml discourse_dev/redis.template.yml")
40end
41
d288199f 42TODO.each do |image|
67446876 43 puts images[image]
67446876
RSS
44
45 dev_deps() if image == :discourse_dev
46 run "(cd base && ./download_phantomjs)" if image == :base
47
48 build(images[image])
49end