kuby-core 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bb1eba2c179a03610f3f478f595c43638e692b41ebad53c7d6292ef5699000a
4
- data.tar.gz: b9003940ecba163e1f9c08100223d6059920f7f9a2d8ebff0c038e1fd5f335ee
3
+ metadata.gz: 5cbd792443dc33de6a20d02f6969f6d59d535f1b68fb75c9a8945615fd870a28
4
+ data.tar.gz: 3add1ef85d6758a2590d35d7aa0bfb4fffaeae55ef6567a34cf3b7557a56e55a
5
5
  SHA512:
6
- metadata.gz: fad183f5c697c6f6a06da8984dff19e0feac91b1996ae79a6605cafb612c77590461f80807ac87854124a97eef31e2999b39a64f997ef4f0fc77564365d81602
7
- data.tar.gz: 1df3f9153d1595d085511329a5c1110117fa626632438a635f162c38cbe9c48d53df3098b28300408b89021365298b9972d07bdb9abd17b01bbc236e711ed3b8
6
+ metadata.gz: 7d855f57aae01d93c2fa44e285ee417ebcc00f12de6f9c4b989a39626ec9ec13a4659eafe0b8924592de5d860666158376e5adbf69c70373703eb2a9074ca75d
7
+ data.tar.gz: dc553aa0b22e5ab262fa18fa1a60bebb421862eab7e747e06c63907fefe8f5371be56415d0bde2e959ffa775140b624aee3aa53006f1dbee272122c87bf53cc6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.16.1
2
+ * Fix a few bugs caused by leaving `continue-on-error: true` in the GitHub actions config 🤦
3
+ - Docker builds would fail if no previous images existed in the registry.
4
+ - The assets image would fail to build because `RAILS_MASTER_KEY` was not propagated correctly.
5
+ * Use the kuby-prebundler gem in the integration tests instead of a custom layer.
6
+
1
7
  ## 0.16.0
2
8
  * Allow Bundler executable to be customized.
3
9
  - Main use-case is to allow adding in the Prebundler plugin, https://github.com/getkuby/kuby-prebundler.
data/lib/kuby/commands.rb CHANGED
@@ -67,6 +67,7 @@ module Kuby
67
67
  c.flag [:a, :arg], required: false, multiple: true
68
68
  c.switch [:'ignore-missing-args'], required: false, default: false
69
69
  c.flag [:only], required: false
70
+ c.flag [:c, :context], required: false
70
71
  c.action do |global_options, options, docker_args|
71
72
  build_args = {}.tap do |build_args|
72
73
  (options[:arg] || []).each do |a|
@@ -79,7 +80,8 @@ module Kuby
79
80
  tasks.build(
80
81
  build_args, docker_args,
81
82
  only: options[:only],
82
- ignore_missing_args: options[:'ignore-missing-args']
83
+ ignore_missing_args: options[:'ignore-missing-args'],
84
+ context: options[:context]
83
85
  )
84
86
  end
85
87
  end
@@ -20,15 +20,6 @@ module Kuby
20
20
  super
21
21
  @identifier = "app"
22
22
  end
23
-
24
- sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).returns(AppImage) }
25
- def build(build_args = {}, docker_args = [])
26
- unless ENV.fetch('RAILS_MASTER_KEY', '').empty?
27
- build_args['RAILS_MASTER_KEY'] = T.must(ENV['RAILS_MASTER_KEY'])
28
- end
29
-
30
- super(build_args, docker_args)
31
- end
32
23
  end
33
24
  end
34
25
  end
@@ -53,8 +53,15 @@ 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], docker_args: T::Array[String]).void }
57
- def build(image, build_args: {}, docker_args: [])
56
+ sig {
57
+ params(
58
+ image: Image,
59
+ build_args: T::Hash[T.any(Symbol, String), String],
60
+ docker_args: T::Array[String],
61
+ context: T.nilable(String)
62
+ ).void
63
+ }
64
+ def build(image, build_args: {}, docker_args: [], context: nil)
58
65
  cmd = [
59
66
  executable, 'build',
60
67
  *image.tags.flat_map { |tag| ['-t', "#{image.image_url}:#{tag}"] },
@@ -63,7 +70,7 @@ module Kuby
63
70
  end,
64
71
  '-f-',
65
72
  *docker_args,
66
- '.'
73
+ context || '.'
67
74
  ]
68
75
 
69
76
  open3_w(cmd) do |stdin, _wait_threads|
@@ -116,8 +116,8 @@ module Kuby
116
116
  [main_tag, *alias_tags].compact
117
117
  end
118
118
 
119
- sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).void }
120
- def build(build_args = {}, docker_args = [])
119
+ sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String], context: T.nilable(String)).void }
120
+ def build(build_args = {}, docker_args = [], context: nil)
121
121
  raise NotImplementedError, 'please use a Docker::Image subclass'
122
122
  end
123
123
 
@@ -31,16 +31,18 @@ module Kuby
31
31
 
32
32
  sig { returns(Image) }
33
33
  def new_version
34
- @new_version ||= duplicate_with_tags(
35
- TimestampTag.new(Time.now).to_s, [Kuby::Docker::LATEST_TAG]
36
- )
34
+ @new_version ||= create_new_version
37
35
  end
38
36
 
39
37
  sig { returns(Image) }
40
38
  def current_version
41
- @current_version ||= duplicate_with_tags(
42
- latest_timestamp_tag.to_s, [Kuby::Docker::LATEST_TAG]
43
- )
39
+ @current_version ||= begin
40
+ duplicate_with_tags(
41
+ latest_timestamp_tag.to_s, [Kuby::Docker::LATEST_TAG]
42
+ )
43
+ rescue MissingTagError
44
+ create_new_version
45
+ end
44
46
  end
45
47
 
46
48
  sig { params(current_tag: T.nilable(String)).returns(Image) }
@@ -74,9 +76,9 @@ module Kuby
74
76
  tag
75
77
  end
76
78
 
77
- sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String]).void }
78
- def build(build_args = {}, docker_args = [])
79
- docker_cli.build(new_version, build_args: build_args, docker_args: docker_args)
79
+ sig { params(build_args: T::Hash[String, String], docker_args: T::Array[String], context: T.nilable(String)).void }
80
+ def build(build_args = {}, docker_args = [], context: nil)
81
+ docker_cli.build(new_version, build_args: build_args, docker_args: docker_args, context: context)
80
82
  @current_version = new_version
81
83
  @new_version = nil
82
84
  end
@@ -88,6 +90,13 @@ module Kuby
88
90
 
89
91
  private
90
92
 
93
+ sig { returns(Image) }
94
+ def create_new_version
95
+ duplicate_with_tags(
96
+ TimestampTag.new(Time.now).to_s, [Kuby::Docker::LATEST_TAG]
97
+ )
98
+ end
99
+
91
100
  sig { returns(::Docker::Remote::Client) }
92
101
  def remote_client
93
102
  @remote_client ||= ::Docker::Remote::Client.new(
@@ -28,12 +28,8 @@ module Kuby
28
28
  )
29
29
  end
30
30
 
31
- def build(build_args = {}, docker_args = [])
32
- unless ENV.fetch('RAILS_MASTER_KEY', '').empty?
33
- build_args['RAILS_MASTER_KEY'] = ENV['RAILS_MASTER_KEY']
34
- end
35
-
36
- docker_cli.build(current_version, build_args: build_args, docker_args: docker_args)
31
+ def build(build_args = {}, docker_args = [], context: nil)
32
+ docker_cli.build(current_version, build_args: build_args, docker_args: docker_args, context: context)
37
33
  end
38
34
 
39
35
  def push(tag)
data/lib/kuby/tasks.rb CHANGED
@@ -28,8 +28,14 @@ module Kuby
28
28
  environment.kubernetes.setup
29
29
  end
30
30
 
31
- def build(build_args = {}, docker_args = [], only: nil, ignore_missing_args: false)
31
+ def build(build_args = {}, docker_args = [], only: nil, ignore_missing_args: false, context: nil)
32
32
  check_platform(docker_args)
33
+
34
+ build_args['RAILS_MASTER_KEY'] ||= ENV['RAILS_MASTER_KEY'] || begin
35
+ master_key_file = File.join('config', 'master.key')
36
+ File.exist?(master_key_file) ? File.read(master_key_file).strip : nil
37
+ end
38
+
33
39
  check_build_args(build_args) unless ignore_missing_args
34
40
 
35
41
  kubernetes.docker_images.each do |image|
@@ -39,7 +45,7 @@ module Kuby
39
45
 
40
46
  image = image.new_version
41
47
  Kuby.logger.info("Building image #{image.image_url} with tags #{image.tags.join(', ')}")
42
- image.build(build_args, docker_args)
48
+ image.build(build_args, docker_args, context: context)
43
49
  end
44
50
  end
45
51
 
data/lib/kuby/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # typed: true
2
2
 
3
3
  module Kuby
4
- VERSION = '0.16.0'.freeze
4
+ VERSION = '0.16.1'.freeze
5
5
  end
@@ -19,8 +19,8 @@ describe Kuby::Docker::TimestampedImage do
19
19
  subject { image.current_version&.main_tag }
20
20
 
21
21
  context 'with no local or remote tags' do
22
- it 'raises an error' do
23
- expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
22
+ it 'creates a new tag' do
23
+ expect(subject).to match(/\d{14}/)
24
24
  end
25
25
  end
26
26
 
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.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-01 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize