argus-builder 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/argus-build +28 -17
- data/lib/argus/docker.rb +3 -3
- data/lib/argus/runner.rb +10 -3
- data/lib/argus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88b9eb34ea2855eef14e84724d8a49746255fb3b
|
4
|
+
data.tar.gz: e0d866df02658db26a327ba49a27c783fbe71721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12b77e5e546de73c42ac94cc4b107009899764a3872505494318171c534928fe6117726a228a7d1d1ec3bd143b1c702f62f51244d9d145c9d3c7e9e180c6b307
|
7
|
+
data.tar.gz: afaa3cfa70c350ce7d88635a5f9d5a9a1dcb1880776a4d299293ee9b9df9f19a39fe697e176c947e599316b5b4aca0c0b182ac74d6c8d8afe31a7bc0adbbc2bc
|
data/README.md
CHANGED
@@ -116,8 +116,8 @@ require 'aws-sdk'
|
|
116
116
|
msg = {
|
117
117
|
org: org,
|
118
118
|
repo: repo,
|
119
|
-
branch: branch,
|
120
|
-
tag: repo:branch # optional
|
119
|
+
branch: branch, # optional, defaults to master
|
120
|
+
tag: repo:branch # optional. defaults to repo:branch
|
121
121
|
}
|
122
122
|
|
123
123
|
sqs = Aws::SQS::Client.new
|
data/bin/argus-build
CHANGED
@@ -2,28 +2,39 @@
|
|
2
2
|
## run a single argus build directly
|
3
3
|
|
4
4
|
require 'argus'
|
5
|
+
require 'optparse'
|
5
6
|
|
6
|
-
|
7
|
+
USAGE = 'argus-build org/repo:branch'
|
7
8
|
|
8
|
-
|
9
|
-
puts "Usage: #{usage}"
|
10
|
-
exit
|
11
|
-
end
|
12
|
-
|
13
|
-
## parse github repo
|
14
|
-
org, repo, branch = ARGV[0].split(/[\/:]+/, 3)
|
15
|
-
sha = ARGV[1] || nil
|
16
|
-
|
17
|
-
## incoming message from sqs
|
9
|
+
## msg to send to argus runner
|
18
10
|
msg = {
|
19
|
-
|
20
|
-
repo: repo,
|
21
|
-
branch: branch,
|
22
|
-
sha: sha
|
11
|
+
build_options: {}
|
23
12
|
}
|
24
13
|
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = USAGE
|
16
|
+
|
17
|
+
opts.on('-s', '--sha SHA', 'Git SHA to build') do |s|
|
18
|
+
msg[:sha] = s
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on('-d', '--dockerfile FILENAME', 'Name of Dockerfile') do |d|
|
22
|
+
msg[:build_options][:dockerfile] = d
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on('-n', '--no-cache', 'Invalidate docker build cache') do |n|
|
26
|
+
msg[:build_options][:nocache] = true
|
27
|
+
end
|
28
|
+
end.parse!
|
29
|
+
|
30
|
+
abort("Usage: #{USAGE}") if ARGV.empty?
|
31
|
+
|
32
|
+
## parse github repo
|
33
|
+
msg[:org], msg[:repo], msg[:branch] = ARGV[0].split(/[\/:]+/, 3)
|
34
|
+
msg.reject! { |_,v| v.nil? }
|
35
|
+
|
25
36
|
## prevent timeout on docker api operations (e.g. long bundle install during build)
|
26
|
-
Excon.defaults[:write_timeout] = ENV.fetch('DOCKER_WRITE_TIMEOUT',
|
27
|
-
Excon.defaults[:read_timeout] = ENV.fetch('DOCKER_READ_TIMEOUT',
|
37
|
+
Excon.defaults[:write_timeout] = ENV.fetch('DOCKER_WRITE_TIMEOUT', 10000)
|
38
|
+
Excon.defaults[:read_timeout] = ENV.fetch('DOCKER_READ_TIMEOUT', 10000)
|
28
39
|
|
29
40
|
Argus::Runner.new(msg)
|
data/lib/argus/docker.rb
CHANGED
@@ -28,12 +28,12 @@ module Argus
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
## build docker image
|
32
|
-
def build!
|
31
|
+
## build docker image, with optional API /build params
|
32
|
+
def build!(options = {})
|
33
33
|
puts "building #{self}"
|
34
34
|
|
35
35
|
@build_time = Benchmark.realtime do
|
36
|
-
@image = Docker::Image.build_from_dir('.',
|
36
|
+
@image = Docker::Image.build_from_dir('.', options) do |chunk|
|
37
37
|
chunk.split(/[\r\n]+/).each do |line| # latest docker jams multiple streams into chunk
|
38
38
|
begin
|
39
39
|
stream = JSON.parse(line)['stream']
|
data/lib/argus/runner.rb
CHANGED
@@ -46,6 +46,10 @@ module Argus
|
|
46
46
|
|
47
47
|
def initialize(msg)
|
48
48
|
msg = symbolize_keys(msg)
|
49
|
+
puts "Received message: #{msg}"
|
50
|
+
|
51
|
+
## set default
|
52
|
+
msg[:branch] ||= 'master'
|
49
53
|
|
50
54
|
## make working directory
|
51
55
|
dir = File.join(ENV.fetch('ARGUS_HOME', '/tmp'), msg[:org], msg[:repo])
|
@@ -65,15 +69,18 @@ module Argus
|
|
65
69
|
git.pull # get the git repo
|
66
70
|
raise ArgusError, "git sha not found: #{git}" unless git.sha
|
67
71
|
|
68
|
-
|
72
|
+
options = msg.fetch(:build_options, {})
|
73
|
+
img.build!(options) # build docker image
|
69
74
|
raise ArgusError, 'docker build failed' unless img.is_ok?
|
70
75
|
|
71
|
-
|
76
|
+
short_sha = git.sha.slice(0,7) # human-readable sha for messages
|
77
|
+
|
78
|
+
notify("build complete for #{img} #{short_sha} (#{img.build_time.round}s)", :good)
|
72
79
|
|
73
80
|
img.tag!(git.sha) # tag the image
|
74
81
|
img.push(git.sha) # push to registry
|
75
82
|
|
76
|
-
notify("push complete for #{img} (#{img.push_time.round}s)", :good)
|
83
|
+
notify("push complete for #{img} #{short_sha} (#{img.push_time.round}s)", :good)
|
77
84
|
end
|
78
85
|
rescue ArgusError => e
|
79
86
|
notify(e.message, :danger)
|
data/lib/argus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argus-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|