kuby-core 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/kuby/commands.rb +11 -6
- data/lib/kuby/docker/app_image.rb +17 -3
- data/lib/kuby/docker/cli.rb +5 -3
- data/lib/kuby/docker/image.rb +6 -2
- data/lib/kuby/docker/timestamped_image.rb +3 -3
- data/lib/kuby/plugins/rails_app/assets.rb +3 -2
- data/lib/kuby/plugins/rails_app/assets_image.rb +3 -2
- data/lib/kuby/tasks.rb +19 -6
- data/lib/kuby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b6d5377f043be7d0aa02cddf817a9dd7fdbaa500c2ed94a2fdb92fa7ef0c1cc
|
4
|
+
data.tar.gz: 57c6cb1a15c4385a7675a05637dbfd085e2b2f438f5429104ec66203e854dd68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c903b0768473d63df1a3ddb9ee3146193abad9c809614f7ccd2e7b7c711a2a3effd3810a3b67780ee68ea3198b8770099fcb3fd4d2a334b39b664f59b8e9e8f
|
7
|
+
data.tar.gz: 69fc8934c14181930c03d3d3ffe050e2da0a85edbbd2f5bba38bf0509131149c643ea42577afcec3a4625057eab52f57bab1e00c3271bedcf491d2e11f1ae696
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.14.0
|
2
|
+
* Make RAILS_MASTER_KEY available in the assets image (@palkan, #63)
|
3
|
+
* Allow specifying custom docker build options via CLI (@palkan, #65)
|
4
|
+
|
1
5
|
## 0.13.0
|
2
6
|
* Fix handling rails/rake options in remote exec (@palkan, #60)
|
3
7
|
* Add `bundler_phase.gemfiles(*paths)` to allow adding additional gemfiles (@palkan, #61)
|
data/lib/kuby/commands.rb
CHANGED
@@ -65,23 +65,25 @@ module Kuby
|
|
65
65
|
desc 'Builds the Docker image.'
|
66
66
|
command :build do |c|
|
67
67
|
c.flag [:a, :arg], required: false, multiple: true
|
68
|
-
c.
|
68
|
+
c.flag [:only], required: false
|
69
|
+
c.action do |global_options, options, docker_args|
|
69
70
|
build_args = {}.tap do |build_args|
|
70
71
|
(options[:arg] || []).each do |a|
|
71
|
-
key, value = a.split('=')
|
72
|
+
key, value = a.split('=', 2)
|
72
73
|
value = value[1..-2] if value.start_with?('"') || value.start_with?("'")
|
73
74
|
build_args[key] = value
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
|
-
tasks.build(build_args)
|
78
|
+
tasks.build(build_args, docker_args, options[:only])
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
82
|
desc 'Pushes the Docker image to the configured registry.'
|
82
83
|
command :push do |c|
|
84
|
+
c.flag [:only], required: false
|
83
85
|
c.action do |global_options, options, args|
|
84
|
-
tasks.push
|
86
|
+
tasks.push(options[:only])
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -94,8 +96,9 @@ module Kuby
|
|
94
96
|
|
95
97
|
desc 'Prints the effective Dockerfiles used to build Docker images.'
|
96
98
|
command :dockerfiles do |c|
|
99
|
+
c.flag [:only], required: false
|
97
100
|
c.action do |global_options, options, args|
|
98
|
-
tasks.print_dockerfiles
|
101
|
+
tasks.print_dockerfiles(options[:only])
|
99
102
|
end
|
100
103
|
end
|
101
104
|
|
@@ -117,8 +120,10 @@ module Kuby
|
|
117
120
|
|
118
121
|
desc 'Prints the effective Kubernetes resources that will be applied on deploy.'
|
119
122
|
command :resources do |c|
|
123
|
+
c.flag [:K, :kind], required: false
|
124
|
+
c.flag [:N, :name], required: false
|
120
125
|
c.action do |global_options, options, args|
|
121
|
-
tasks.print_resources
|
126
|
+
tasks.print_resources(options[:kind], options[:name])
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
@@ -6,13 +6,27 @@ module Kuby
|
|
6
6
|
class AppImage < ::Kuby::Docker::TimestampedImage
|
7
7
|
extend T::Sig
|
8
8
|
|
9
|
-
sig {
|
10
|
-
|
9
|
+
sig {
|
10
|
+
params(
|
11
|
+
dockerfile: T.any(Dockerfile, T.proc.returns(Dockerfile)),
|
12
|
+
image_url: String,
|
13
|
+
credentials: Credentials,
|
14
|
+
main_tag: T.nilable(String),
|
15
|
+
alias_tags: T::Array[String]
|
16
|
+
).void
|
17
|
+
}
|
18
|
+
def initialize(dockerfile, image_url, credentials, main_tag = nil, alias_tags = [])
|
19
|
+
super
|
20
|
+
@identifier = "app"
|
21
|
+
end
|
22
|
+
|
23
|
+
sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).returns(AppImage) }
|
24
|
+
def build(build_args = {}, docker_args = [])
|
11
25
|
unless ENV.fetch('RAILS_MASTER_KEY', '').empty?
|
12
26
|
build_args['RAILS_MASTER_KEY'] = T.must(ENV['RAILS_MASTER_KEY'])
|
13
27
|
end
|
14
28
|
|
15
|
-
super(build_args)
|
29
|
+
super(build_args, docker_args)
|
16
30
|
end
|
17
31
|
end
|
18
32
|
end
|
data/lib/kuby/docker/cli.rb
CHANGED
@@ -53,15 +53,17 @@ module Kuby
|
|
53
53
|
config.fetch('auths', {}).keys
|
54
54
|
end
|
55
55
|
|
56
|
-
sig { params(image: Image, build_args: T::Hash[T.any(Symbol, String), String]).void }
|
57
|
-
def build(image, build_args: {})
|
56
|
+
sig { params(image: Image, build_args: T::Hash[T.any(Symbol, String), String], docker_args: T::Array[String]).void }
|
57
|
+
def build(image, build_args: {}, docker_args: [])
|
58
58
|
cmd = [
|
59
59
|
executable, 'build',
|
60
60
|
*image.tags.flat_map { |tag| ['-t', "#{image.image_url}:#{tag}"] },
|
61
61
|
*build_args.flat_map do |arg, val|
|
62
62
|
['--build-arg', Shellwords.shellescape("#{arg}=#{val}")]
|
63
63
|
end,
|
64
|
-
'-f-',
|
64
|
+
'-f-',
|
65
|
+
*docker_args,
|
66
|
+
'.'
|
65
67
|
]
|
66
68
|
|
67
69
|
open3_w(cmd) do |stdin, _wait_threads|
|
data/lib/kuby/docker/image.rb
CHANGED
@@ -5,6 +5,9 @@ module Kuby
|
|
5
5
|
class Image
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
+
sig { returns(T.nilable(String)) }
|
9
|
+
attr_reader :identifier
|
10
|
+
|
8
11
|
sig { returns(String) }
|
9
12
|
attr_reader :image_url
|
10
13
|
|
@@ -32,6 +35,7 @@ module Kuby
|
|
32
35
|
@credentials = T.let(credentials, Credentials)
|
33
36
|
@main_tag = T.let(main_tag, T.nilable(String))
|
34
37
|
@alias_tags = T.let(alias_tags, T::Array[String])
|
38
|
+
@identifier = T.let(@identifier, T.nilable(String))
|
35
39
|
|
36
40
|
@image_host = T.let(@image_host, T.nilable(String))
|
37
41
|
@image_hostname = T.let(@image_hostname, T.nilable(String))
|
@@ -89,8 +93,8 @@ module Kuby
|
|
89
93
|
[main_tag, *alias_tags].compact
|
90
94
|
end
|
91
95
|
|
92
|
-
sig { params(build_args: T::Hash[String, String]).void }
|
93
|
-
def build(build_args = {})
|
96
|
+
sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).void }
|
97
|
+
def build(build_args = {}, docker_args = [])
|
94
98
|
raise NotImplementedError, 'please use a Docker::Image subclass'
|
95
99
|
end
|
96
100
|
|
@@ -73,9 +73,9 @@ module Kuby
|
|
73
73
|
tag
|
74
74
|
end
|
75
75
|
|
76
|
-
sig { params(build_args: T::Hash[String, String]).void }
|
77
|
-
def build(build_args = {})
|
78
|
-
docker_cli.build(new_version, build_args: build_args)
|
76
|
+
sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).void }
|
77
|
+
def build(build_args = {}, docker_args = [])
|
78
|
+
docker_cli.build(new_version, build_args: build_args, docker_args: docker_args)
|
79
79
|
@current_version = new_version
|
80
80
|
@new_version = nil
|
81
81
|
end
|
@@ -317,14 +317,15 @@ module Kuby
|
|
317
317
|
tags.each_cons(2) do |prev_tag, tag|
|
318
318
|
prev_image_name = "#{app_name}-#{prev_tag}"
|
319
319
|
df.from("#{base_image.image_url}:#{prev_tag}", as: prev_image_name)
|
320
|
+
df.arg('RAILS_MASTER_KEY')
|
320
321
|
df.run("mkdir -p #{RAILS_MOUNT_PATH}")
|
321
|
-
df.run("bundle exec rake kuby:rails_app:assets:copy")
|
322
|
+
df.run("env RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rake kuby:rails_app:assets:copy")
|
322
323
|
|
323
324
|
if tag
|
324
325
|
image_name = "#{app_name}-#{tag}"
|
325
326
|
df.from("#{base_image.image_url}:#{tag}", as: image_name)
|
326
327
|
df.copy("--from=#{prev_image_name} #{RAILS_MOUNT_PATH}", RAILS_MOUNT_PATH)
|
327
|
-
df.run("bundle exec rake kuby:rails_app:assets:copy")
|
328
|
+
df.run("env RAILS_MASTER_KEY=$RAILS_MASTER_KEY bundle exec rake kuby:rails_app:assets:copy")
|
328
329
|
end
|
329
330
|
end
|
330
331
|
|
@@ -7,6 +7,7 @@ module Kuby
|
|
7
7
|
def initialize(base_image, dockerfile, main_tag = nil, alias_tags = [])
|
8
8
|
super(dockerfile, base_image.image_url, base_image.credentials, main_tag, alias_tags)
|
9
9
|
@base_image = base_image
|
10
|
+
@identifier = "assets"
|
10
11
|
end
|
11
12
|
|
12
13
|
def new_version
|
@@ -27,8 +28,8 @@ module Kuby
|
|
27
28
|
)
|
28
29
|
end
|
29
30
|
|
30
|
-
def build(build_args = {})
|
31
|
-
docker_cli.build(current_version, build_args: build_args)
|
31
|
+
def build(build_args = {}, docker_args = [])
|
32
|
+
docker_cli.build(current_version, build_args: build_args, docker_args: docker_args)
|
32
33
|
end
|
33
34
|
|
34
35
|
def push(tag)
|
data/lib/kuby/tasks.rb
CHANGED
@@ -9,10 +9,13 @@ module Kuby
|
|
9
9
|
@environment = environment
|
10
10
|
end
|
11
11
|
|
12
|
-
def print_dockerfiles
|
12
|
+
def print_dockerfiles(only = nil)
|
13
13
|
kubernetes.docker_images.each do |image|
|
14
|
+
next if only && image.identifier != only
|
15
|
+
|
14
16
|
image = image.current_version
|
15
|
-
|
17
|
+
identifier = image.identifier ? " ##{image.identifier}" : ""
|
18
|
+
Kuby.logger.info("Dockerfile for#{identifier} image #{image.image_url} with tags #{image.tags.join(', ')}")
|
16
19
|
theme = Rouge::Themes::Base16::Solarized.new
|
17
20
|
formatter = Rouge::Formatters::Terminal256.new(theme)
|
18
21
|
lexer = Rouge::Lexers::Docker.new
|
@@ -25,16 +28,20 @@ module Kuby
|
|
25
28
|
environment.kubernetes.setup
|
26
29
|
end
|
27
30
|
|
28
|
-
def build(build_args = {})
|
31
|
+
def build(build_args = {}, docker_args = [], only = nil)
|
29
32
|
kubernetes.docker_images.each do |image|
|
33
|
+
next if only && image.identifier != only
|
34
|
+
|
30
35
|
image = image.new_version
|
31
36
|
Kuby.logger.info("Building image #{image.image_url} with tags #{image.tags.join(', ')}")
|
32
|
-
image.build(build_args)
|
37
|
+
image.build(build_args, docker_args)
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
|
-
def push
|
41
|
+
def push(only = nil)
|
37
42
|
kubernetes.docker_images.each do |image|
|
43
|
+
next if only && image.identifier != only
|
44
|
+
|
38
45
|
image = image.current_version
|
39
46
|
Kuby.logger.info("Pushing image #{image.image_url} with tags #{image.tags.join(', ')}")
|
40
47
|
push_image(image)
|
@@ -77,10 +84,16 @@ module Kuby
|
|
77
84
|
environment.kubernetes.rollback
|
78
85
|
end
|
79
86
|
|
80
|
-
def print_resources
|
87
|
+
def print_resources(kind = nil, name_pattern = nil)
|
81
88
|
kubernetes.before_deploy
|
82
89
|
|
90
|
+
name_rxp = Regexp.new(name_pattern) if name_pattern
|
91
|
+
|
83
92
|
kubernetes.resources.each do |res|
|
93
|
+
next if kind && res.kind_sym.to_s != kind
|
94
|
+
|
95
|
+
next if name_rxp && !name_rxp.match?(res.metadata.name)
|
96
|
+
|
84
97
|
puts res.to_resource.serialize.to_yaml
|
85
98
|
end
|
86
99
|
end
|
data/lib/kuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|