forked from trashpanda001/docker-alpine-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·35 lines (30 loc) · 1003 Bytes
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
require "erb"
repo="sickp/alpine-nginx"
nginx_version = ARGV.first
case nginx_version
when /\A1\.11\.\d+\z/
branch = "mainline"
tags = %w(1.11 mainline latest)
when /\A1\.10\.\d+\z/
branch = "stable"
tags = %w(1.10 stable)
when /\A1\.8\.\d+\z/
branch = "legacy"
tags = %w(1.8 legacy)
else
puts "Usage: build <nginx-version>"
puts " <nginx-version> = 1.8.x | 1.10.x | 1.11.x"
exit 1
end
template = ERB.new(File.read(File.join(File.dirname(__FILE__), "templates", "Dockerfile.#{branch}.erb")))
base_image = "alpine:3.4"
dockerfile = File.join(File.dirname(__FILE__), "versions", nginx_version, "Dockerfile")
Dir.mkdir(File.dirname(dockerfile)) rescue nil
File.write(dockerfile, template.result(binding))
system("docker build -t #{repo}:#{nginx_version} --pull versions/#{nginx_version}") || abort
puts "Built #{repo}:#{nginx_version}"
tags.each do |tag|
system("docker tag #{repo}:#{nginx_version} #{repo}:#{tag}") || abort
puts "Tagged #{repo}:#{tag}"
end