-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdockertool.rb
executable file
·56 lines (48 loc) · 1.06 KB
/
dockertool.rb
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ruby
# frozen_string_literal: true
require "yaml"
require "childprocess"
INFO = YAML.load_file("info/version.yml").freeze
CODENAME = INFO["codename"].downcase
VERSION = INFO["version"]
REGISTRY = "registry.gitlab.com"
NAMESPACE = "lu-ci/sigma"
IMAGE = "apex-sigma"
def tagged(tag)
"#{REGISTRY}/#{NAMESPACE}/#{IMAGE}:#{tag}"
end
@tags = [
tagged(CODENAME),
tagged("#{VERSION['major']}.#{VERSION['minor']}.#{VERSION['patch']}"),
tagged("#{VERSION['major']}.#{VERSION['minor']}"),
tagged(VERSION['major']),
tagged("latest")
].freeze
def build
tags = @tags.flat_map { |t| ["--tag", t] }
cmd = ["docker", "build"] + tags << "."
ChildProcess.build(*cmd).tap do |p|
p.io.stdout = $stdout
p.io.stderr = $stderr
p.start
p.wait
end
end
def push
@tags.each do |tag|
ChildProcess.build("docker", "push", tag).tap do |p|
p.io.stdout = $stdout
p.io.stderr = $stderr
p.start
p.wait
end
end
end
def show
puts @tags
end
case ARGV.first
when "build" then build
when "push" then push
when "show" then show
end