service_image_builder 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +34 -11
- data/.rubocop.yml +2 -1
- data/Gemfile.lock +64 -57
- data/bin/sib +16 -2
- data/lib/service_image_builder/errors.rb +1 -0
- data/lib/service_image_builder/image.rb +6 -1
- data/lib/service_image_builder/logger.rb +1 -1
- data/lib/service_image_builder/version.rb +1 -1
- data/service_image_builder.gemspec +10 -11
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3352dd551ce1f10d6d86399cebb70eacb98371b2f058898cbaa28b24a7fe233e
|
4
|
+
data.tar.gz: eae047d41225843eb3bdf18c0374cce6dc70cbf14c0d931e2eb1b7782eca0772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44596d167f33a4a5abadeb51135714371d55a0fff7107d63073d59f67f5029eefc3e27afdb2d0368e1ecfbe34d244410784a6f051eb098811daf1855352f8390
|
7
|
+
data.tar.gz: 7ddc2ffe7e8860fd2ba65dea262300ae1cb6b2a60756d111e930c456952f6a4901d6070461e2eb352d2839b0951470fd16f0ec5613f5864a6e9b1f9b3b1eeee0
|
data/.gitlab-ci.yml
CHANGED
@@ -1,14 +1,37 @@
|
|
1
|
-
|
1
|
+
variables:
|
2
|
+
DOCKER_DRIVER: overlay2
|
3
|
+
DOCKER_HOST: tcp://docker:2375/
|
4
|
+
SIB_IMAGE_REPO: slushsystems/service_image_builder
|
2
5
|
|
3
|
-
|
4
|
-
paths:
|
5
|
-
- vendor/
|
6
|
-
|
7
|
-
before_script:
|
8
|
-
- bundle install --deployment
|
9
|
-
|
10
|
-
pre-flight check:
|
6
|
+
build pr:
|
11
7
|
stage: test
|
8
|
+
image: slushsystems/ruby:latest
|
9
|
+
services:
|
10
|
+
- name: docker:dind
|
11
|
+
command: ["dockerd-entrypoint.sh", "--experimental"]
|
12
|
+
cache:
|
13
|
+
paths:
|
14
|
+
- vendor/
|
15
|
+
variables:
|
16
|
+
SIB_PUSH: "false"
|
17
|
+
except:
|
18
|
+
- master
|
19
|
+
before_script:
|
20
|
+
- bundle install --deployment
|
21
|
+
script:
|
22
|
+
- bundle exec rake
|
23
|
+
- bundle exec rubocop
|
24
|
+
- bundle exec bin/sib
|
25
|
+
|
26
|
+
build master & push:
|
27
|
+
stage: deploy
|
28
|
+
image: slushsystems/ruby:latest
|
29
|
+
services:
|
30
|
+
- name: docker:dind
|
31
|
+
command: ["dockerd-entrypoint.sh", "--experimental"]
|
32
|
+
only:
|
33
|
+
- master
|
34
|
+
before_script:
|
35
|
+
- bundle install --deployment
|
12
36
|
script:
|
13
|
-
|
14
|
-
- bundle exec rubocop
|
37
|
+
- bundle exec bin/sib
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,85 +2,92 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
service_image_builder (0.1.3)
|
5
|
-
activesupport (~>
|
6
|
-
awesome_print (~> 1.
|
7
|
-
docker-api (~> 1
|
5
|
+
activesupport (~> 6.1)
|
6
|
+
awesome_print (~> 1.9)
|
7
|
+
docker-api (~> 2.1)
|
8
8
|
logger (~> 1.4, >= 1.4.2)
|
9
|
-
oj (~> 3.
|
9
|
+
oj (~> 3.11)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (
|
14
|
+
activesupport (6.1.3.1)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
-
i18n (>=
|
17
|
-
minitest (
|
18
|
-
tzinfo (~>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
tzinfo (~> 2.0)
|
19
|
+
zeitwerk (~> 2.3)
|
20
|
+
ast (2.4.2)
|
21
|
+
awesome_print (1.9.2)
|
22
|
+
byebug (11.1.3)
|
23
|
+
coderay (1.1.3)
|
24
|
+
concurrent-ruby (1.1.8)
|
25
|
+
diff-lcs (1.4.4)
|
26
|
+
docker-api (2.1.0)
|
26
27
|
excon (>= 0.47.0)
|
27
28
|
multi_json
|
28
|
-
excon (0.
|
29
|
-
i18n (1.
|
29
|
+
excon (0.80.1)
|
30
|
+
i18n (1.8.10)
|
30
31
|
concurrent-ruby (~> 1.0)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
pry-byebug (3.7.0)
|
32
|
+
logger (1.4.3)
|
33
|
+
method_source (1.0.0)
|
34
|
+
minitest (5.14.4)
|
35
|
+
multi_json (1.15.0)
|
36
|
+
oj (3.11.5)
|
37
|
+
parallel (1.20.1)
|
38
|
+
parser (3.0.1.0)
|
39
|
+
ast (~> 2.4.1)
|
40
|
+
pry (0.13.1)
|
41
|
+
coderay (~> 1.1)
|
42
|
+
method_source (~> 1.0)
|
43
|
+
pry-byebug (3.9.0)
|
44
44
|
byebug (~> 11.0)
|
45
|
-
pry (~> 0.
|
45
|
+
pry (~> 0.13.0)
|
46
46
|
rainbow (3.0.0)
|
47
|
-
rake (
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
rspec-
|
52
|
-
|
53
|
-
rspec-
|
54
|
-
rspec-
|
47
|
+
rake (13.0.3)
|
48
|
+
regexp_parser (2.1.1)
|
49
|
+
rexml (3.2.5)
|
50
|
+
rspec (3.10.0)
|
51
|
+
rspec-core (~> 3.10.0)
|
52
|
+
rspec-expectations (~> 3.10.0)
|
53
|
+
rspec-mocks (~> 3.10.0)
|
54
|
+
rspec-core (3.10.1)
|
55
|
+
rspec-support (~> 3.10.0)
|
56
|
+
rspec-expectations (3.10.1)
|
55
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
-
rspec-support (~> 3.
|
57
|
-
rspec-mocks (3.
|
58
|
+
rspec-support (~> 3.10.0)
|
59
|
+
rspec-mocks (3.10.2)
|
58
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
-
rspec-support (~> 3.
|
60
|
-
rspec-support (3.
|
61
|
-
rubocop (
|
62
|
-
jaro_winkler (~> 1.5.1)
|
61
|
+
rspec-support (~> 3.10.0)
|
62
|
+
rspec-support (3.10.2)
|
63
|
+
rubocop (1.13.0)
|
63
64
|
parallel (~> 1.10)
|
64
|
-
parser (>=
|
65
|
+
parser (>= 3.0.0.0)
|
65
66
|
rainbow (>= 2.2.2, < 4.0)
|
67
|
+
regexp_parser (>= 1.8, < 3.0)
|
68
|
+
rexml
|
69
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
66
70
|
ruby-progressbar (~> 1.7)
|
67
|
-
unicode-display_width (>= 1.4.0, <
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
72
|
+
rubocop-ast (1.4.1)
|
73
|
+
parser (>= 2.7.1.5)
|
74
|
+
ruby-progressbar (1.11.0)
|
75
|
+
tzinfo (2.0.4)
|
76
|
+
concurrent-ruby (~> 1.0)
|
77
|
+
unicode-display_width (2.0.0)
|
78
|
+
zeitwerk (2.4.2)
|
73
79
|
|
74
80
|
PLATFORMS
|
75
81
|
ruby
|
82
|
+
x86_64-darwin-20
|
76
83
|
|
77
84
|
DEPENDENCIES
|
78
85
|
bundler (~> 2)
|
79
|
-
pry-byebug (~> 3.
|
80
|
-
rake (~>
|
81
|
-
rspec (~> 3.
|
82
|
-
rubocop (~>
|
86
|
+
pry-byebug (~> 3.9)
|
87
|
+
rake (~> 13.0)
|
88
|
+
rspec (~> 3.10)
|
89
|
+
rubocop (~> 1.13)
|
83
90
|
service_image_builder!
|
84
91
|
|
85
92
|
BUNDLED WITH
|
86
|
-
2.0
|
93
|
+
2.2.0
|
data/bin/sib
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative '../lib/service_image_builder
|
4
|
+
require_relative '../lib/service_image_builder'
|
5
5
|
|
6
6
|
# This is a sha256 sum of the ouput of `dnf list installed` which contains a
|
7
7
|
# list of installed packages and their associated versions. A change in this
|
@@ -21,8 +21,22 @@ image_repo = ENV.fetch('SIB_IMAGE_REPO')
|
|
21
21
|
image_upstream_tag = ENV.fetch('SIB_UPSTREAM_TAG', 'latest')
|
22
22
|
registry_pass = ENV.fetch('SIB_REGISTRY_PASS')
|
23
23
|
registry_user = ENV.fetch('SIB_REGISTRY_USER')
|
24
|
+
push = ENV.fetch('SIB_PUSH', true)
|
24
25
|
squash = ENV.fetch('SIB_SQUASH', false)
|
25
26
|
|
27
|
+
# Convert boolean vars
|
28
|
+
# TODO put this in a configuration class
|
29
|
+
def bool!(input)
|
30
|
+
return input if input.is_a?(TrueClass) || input.is_a?(FalseClass)
|
31
|
+
return true if input == 'true'
|
32
|
+
return false if input == 'false'
|
33
|
+
|
34
|
+
raise 'Invalid boolean input'
|
35
|
+
end
|
36
|
+
|
37
|
+
push = bool!(push)
|
38
|
+
squash = bool!(squash)
|
39
|
+
|
26
40
|
Docker.authenticate!('username' => registry_user, 'password' => registry_pass)
|
27
41
|
|
28
42
|
upstream = SIB::Image.import(repo: image_repo, tag: image_upstream_tag)
|
@@ -41,7 +55,7 @@ build_args = {
|
|
41
55
|
|
42
56
|
canary = SIB::Image.build(build_args)
|
43
57
|
|
44
|
-
if upstream.nil? || (canary <=> upstream).positive?
|
58
|
+
if push && (upstream.nil? || (canary <=> upstream).positive?)
|
45
59
|
canary.push_tag(tag: image_upstream_tag)
|
46
60
|
canary.push_tag(tag: canary.factor_hash)
|
47
61
|
end
|
@@ -4,10 +4,13 @@ module SIB
|
|
4
4
|
# SIB::ImageError is raised when an unrecoverable error occurs in Image
|
5
5
|
# operations
|
6
6
|
class ImageError < SIB::Error; end
|
7
|
+
|
7
8
|
# SIB::Image represents a docker image
|
8
9
|
class Image
|
9
10
|
attr_accessor :image, :repo
|
10
11
|
|
12
|
+
# TODO: Fix
|
13
|
+
# rubocop:disable Metrics/MethodLength
|
11
14
|
def self.build(repo:, build_dir:, dockerfile: 'Dockerfile', labels: {}, squash: false)
|
12
15
|
build_dir ||= Dir.pwd
|
13
16
|
build_args = {
|
@@ -27,6 +30,7 @@ module SIB
|
|
27
30
|
|
28
31
|
new(repo: repo, image: image)
|
29
32
|
end
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
30
34
|
|
31
35
|
def self.import(repo:, tag:)
|
32
36
|
new(repo: repo, image: Docker::Image.create('fromImage' => "#{repo}:#{tag}"))
|
@@ -108,7 +112,8 @@ module SIB
|
|
108
112
|
def parse_api_response(response)
|
109
113
|
response.split("\r\n").map { |r| Oj.load(r) }
|
110
114
|
rescue Oj::Error => e
|
111
|
-
|
115
|
+
SIB.log.error("Couldn't JSON parse api response: #{e.message}")
|
116
|
+
SIB.log.info("Unparseable message: #{response}")
|
112
117
|
end
|
113
118
|
end
|
114
119
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
module SIB
|
5
5
|
# SIB::log serves as a module-level logging method
|
6
6
|
def self.log
|
7
|
-
@log ||= Logger.new(
|
7
|
+
@log ||= Logger.new($stdout).tap do |lager|
|
8
8
|
lager.formatter = proc do |severity, datetime, progname, msg|
|
9
9
|
out = msg.is_a?(String) ? msg : msg.ai(multiline: false)
|
10
10
|
"#{datetime} #{severity} #{progname}: #{out}\n"
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'service_image_builder/version'
|
5
4
|
|
@@ -23,22 +22,22 @@ registry.'
|
|
23
22
|
|
24
23
|
# Specify which files should be added to the gem when it is released.
|
25
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
-
spec.files = Dir.chdir(File.expand_path(
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
27
|
end
|
29
28
|
spec.bindir = 'bin'
|
30
29
|
spec.executables = 'sib'
|
31
30
|
spec.require_paths = ['lib']
|
32
31
|
|
33
|
-
spec.add_dependency 'activesupport', '~>
|
34
|
-
spec.add_dependency 'awesome_print', '~> 1.
|
35
|
-
spec.add_dependency 'docker-api', '~> 1
|
32
|
+
spec.add_dependency 'activesupport', '~> 6.1'
|
33
|
+
spec.add_dependency 'awesome_print', '~> 1.9'
|
34
|
+
spec.add_dependency 'docker-api', '~> 2.1'
|
36
35
|
spec.add_dependency 'logger', '~> 1.4', '>= 1.4.2'
|
37
|
-
spec.add_dependency 'oj', '~> 3.
|
36
|
+
spec.add_dependency 'oj', '~> 3.11'
|
38
37
|
|
39
38
|
spec.add_development_dependency 'bundler', '~> 2'
|
40
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.
|
41
|
-
spec.add_development_dependency 'rake', '~>
|
42
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
43
|
-
spec.add_development_dependency 'rubocop', '~>
|
39
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
40
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
42
|
+
spec.add_development_dependency 'rubocop', '~> 1.13'
|
44
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_image_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Jacobs
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: awesome_print
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.9'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: docker-api
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '2.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: logger
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '3.
|
81
|
+
version: '3.11'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '3.
|
88
|
+
version: '3.11'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: bundler
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,56 +106,56 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
109
|
+
version: '3.9'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3.
|
116
|
+
version: '3.9'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rake
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
123
|
+
version: '13.0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
130
|
+
version: '13.0'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rspec
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '3.
|
137
|
+
version: '3.10'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: '3.
|
144
|
+
version: '3.10'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: rubocop
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
151
|
+
version: '1.13'
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
158
|
+
version: '1.13'
|
159
159
|
description: |-
|
160
160
|
This is a Slush Systems tool for building service images. Slush Systems
|
161
161
|
creates continuously updated and deployed infrastructure and tooling
|
@@ -195,7 +195,7 @@ metadata:
|
|
195
195
|
homepage_uri: https://slush.systems/
|
196
196
|
source_code_uri: https://gitlab.com/slush-systems/service_image_builder
|
197
197
|
changelog_uri: https://gitlab.com/slush-systems/service_image_builder/commits/master
|
198
|
-
post_install_message:
|
198
|
+
post_install_message:
|
199
199
|
rdoc_options: []
|
200
200
|
require_paths:
|
201
201
|
- lib
|
@@ -210,8 +210,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
214
|
-
signing_key:
|
213
|
+
rubygems_version: 3.1.4
|
214
|
+
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: A tool for building and deploying Slush Systems Service Images
|
217
217
|
test_files: []
|