improve build

This commit is contained in:
Sam 2015-04-15 14:16:39 +10:00
parent 31b15c200e
commit 7b3345bacc
3 changed files with 40 additions and 1 deletions

View File

@ -1,5 +1,5 @@
FROM gliderlabs/alpine
ADD build/discourse-auth-proxy /bin/discourse-auth-proxy
ADD build_image/discourse-auth-proxy /bin/discourse-auth-proxy
CMD ["/bin/discourse-auth-proxy"]

39
docker/build.rb Normal file
View File

@ -0,0 +1,39 @@
require 'pty'
version = "1.0.0"
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(path)
lines = run("cd #{path} && docker build --nocache .")
lines[-1]["successfully built ".length..-1].strip
end
img = build("build_image")
pwd = `pwd`.strip
run "docker run --rm -it -v #{pwd}/build_image:/shared #{img}"
repo = "samsaffron/discourse-auth-proxy"
tag = "#{repo}:#{version}"
latest = "#{repo}:#{latest}"
img = build(".")
run "docker tag #{img} #{tag}"
run "docker tag #{img} #{latest}"