kuby-core 0.11.16 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -2
- data/kuby-core.gemspec +1 -1
- data/lib/kuby.rb +2 -20
- data/lib/kuby/commands.rb +13 -67
- data/lib/kuby/docker.rb +27 -25
- data/lib/kuby/docker/alpine.rb +2 -1
- data/lib/kuby/docker/app_image.rb +19 -0
- data/lib/kuby/docker/cli.rb +4 -12
- data/lib/kuby/docker/docker_uri.rb +18 -7
- data/lib/kuby/docker/errors.rb +1 -19
- data/lib/kuby/docker/image.rb +115 -0
- data/lib/kuby/docker/layer.rb +0 -7
- data/lib/kuby/docker/local_tags.rb +9 -10
- data/lib/kuby/docker/package_phase.rb +0 -5
- data/lib/kuby/docker/packages.rb +1 -0
- data/lib/kuby/docker/remote_tags.rb +10 -5
- data/lib/kuby/docker/setup_phase.rb +17 -9
- data/lib/kuby/docker/spec.rb +29 -62
- data/lib/kuby/docker/timestamp_tag.rb +8 -1
- data/lib/kuby/docker/timestamped_image.rb +113 -0
- data/lib/kuby/environment.rb +1 -10
- data/lib/kuby/kubernetes/bare_metal_provider.rb +16 -4
- data/lib/kuby/kubernetes/deployer.rb +1 -1
- data/lib/kuby/kubernetes/docker_desktop_provider.rb +0 -15
- data/lib/kuby/kubernetes/spec.rb +21 -17
- data/lib/kuby/plugin.rb +2 -2
- data/lib/kuby/plugins/rails_app.rb +1 -0
- data/lib/kuby/plugins/rails_app/assets.rb +60 -70
- data/lib/kuby/plugins/rails_app/assets_image.rb +55 -0
- data/lib/kuby/plugins/rails_app/plugin.rb +53 -236
- data/lib/kuby/tasks.rb +30 -69
- data/lib/kuby/version.rb +1 -1
- data/spec/docker/spec_spec.rb +9 -118
- data/spec/docker/timestamped_image_spec.rb +123 -0
- data/spec/spec_helper.rb +10 -11
- metadata +9 -10
- data/lib/kuby/dev_setup.rb +0 -346
- data/lib/kuby/docker/dev_spec.rb +0 -202
- data/lib/kuby/docker/metadata.rb +0 -90
- data/lib/kuby/docker/tags.rb +0 -92
- data/lib/kuby/rails_commands.rb +0 -84
- data/spec/docker/metadata_spec.rb +0 -73
data/lib/kuby/version.rb
CHANGED
data/spec/docker/spec_spec.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# typed: false
|
2
2
|
require 'spec_helper'
|
3
|
-
require 'timecop'
|
4
3
|
|
5
4
|
describe Kuby::Docker::Spec do
|
6
5
|
let(:spec) { definition.environment.docker }
|
7
6
|
|
8
7
|
describe '#base_image' do
|
9
|
-
subject { spec.
|
8
|
+
subject { spec.image.dockerfile.to_s }
|
10
9
|
|
11
10
|
it 'uses the default base image for Debian' do
|
12
11
|
expect(subject).to include("FROM ruby:#{RUBY_VERSION}\n")
|
@@ -34,7 +33,7 @@ describe Kuby::Docker::Spec do
|
|
34
33
|
Kuby::Docker::SetupPhase::DEFAULT_WORKING_DIR
|
35
34
|
end
|
36
35
|
|
37
|
-
subject { spec.
|
36
|
+
subject { spec.image.dockerfile.to_s }
|
38
37
|
|
39
38
|
it 'uses the default working dir' do
|
40
39
|
expect(subject).to(
|
@@ -52,7 +51,7 @@ describe Kuby::Docker::Spec do
|
|
52
51
|
end
|
53
52
|
|
54
53
|
describe '#rails_env' do
|
55
|
-
subject { spec.
|
54
|
+
subject { spec.image.dockerfile.to_s }
|
56
55
|
|
57
56
|
it 'uses the name of the current Kuby environment' do
|
58
57
|
expect(subject).to include("ENV RAILS_ENV=#{spec.environment.name}\n")
|
@@ -73,7 +72,7 @@ describe Kuby::Docker::Spec do
|
|
73
72
|
end
|
74
73
|
|
75
74
|
describe '#bundler_version' do
|
76
|
-
subject { spec.
|
75
|
+
subject { spec.image.dockerfile.to_s }
|
77
76
|
|
78
77
|
it 'installs the current bundler version' do
|
79
78
|
expect(subject).to(
|
@@ -91,7 +90,7 @@ describe Kuby::Docker::Spec do
|
|
91
90
|
end
|
92
91
|
|
93
92
|
describe '#gemfile' do
|
94
|
-
subject { spec.
|
93
|
+
subject { spec.image.dockerfile.to_s }
|
95
94
|
|
96
95
|
it 'uses the default Gemfile' do
|
97
96
|
expect(subject).to include("COPY Gemfile .\n")
|
@@ -111,7 +110,7 @@ describe Kuby::Docker::Spec do
|
|
111
110
|
end
|
112
111
|
|
113
112
|
describe '#package' do
|
114
|
-
subject { spec.
|
113
|
+
subject { spec.image.dockerfile.to_s }
|
115
114
|
|
116
115
|
it 'installs the given package' do
|
117
116
|
# configured in spec_helper.rb
|
@@ -122,7 +121,7 @@ describe Kuby::Docker::Spec do
|
|
122
121
|
end
|
123
122
|
|
124
123
|
describe '#files' do
|
125
|
-
subject { spec.
|
124
|
+
subject { spec.image.dockerfile.to_s }
|
126
125
|
|
127
126
|
it 'copies the current directory contents by default' do
|
128
127
|
expect(subject).to include("COPY ./ .\n")
|
@@ -142,7 +141,7 @@ describe Kuby::Docker::Spec do
|
|
142
141
|
Kuby::Docker::WebserverPhase::DEFAULT_PORT
|
143
142
|
end
|
144
143
|
|
145
|
-
subject { spec.
|
144
|
+
subject { spec.image.dockerfile.to_s }
|
146
145
|
|
147
146
|
it 'exposes the default port' do
|
148
147
|
expect(subject).to include("EXPOSE #{default_port}\n")
|
@@ -157,116 +156,8 @@ describe Kuby::Docker::Spec do
|
|
157
156
|
end
|
158
157
|
end
|
159
158
|
|
160
|
-
describe '#tag' do
|
161
|
-
let(:tag) { make_ts_tag(Time.now) }
|
162
|
-
|
163
|
-
subject { spec.tag }
|
164
|
-
|
165
|
-
context 'with no local or remote tags' do
|
166
|
-
it 'raises an error' do
|
167
|
-
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'with an available remote tag' do
|
172
|
-
before { docker_remote_client.tags << tag }
|
173
|
-
|
174
|
-
it { is_expected.to eq(tag) }
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'with an available local tag' do
|
178
|
-
before do
|
179
|
-
docker_cli.build(
|
180
|
-
dockerfile: nil,
|
181
|
-
image_url: docker_image_url,
|
182
|
-
tags: [tag]
|
183
|
-
)
|
184
|
-
end
|
185
|
-
|
186
|
-
it { is_expected.to eq(tag) }
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'with multiple remote tags' do
|
190
|
-
let(:time) { Time.now }
|
191
|
-
|
192
|
-
before do
|
193
|
-
docker_remote_client.tags +=
|
194
|
-
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
195
|
-
make_ts_tag(t)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it { is_expected.to eq(make_ts_tag(time + 15)) }
|
200
|
-
end
|
201
|
-
|
202
|
-
context 'with multiple local and remote tags' do
|
203
|
-
let(:time) { Time.now }
|
204
|
-
|
205
|
-
before do
|
206
|
-
docker_remote_client.tags +=
|
207
|
-
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
208
|
-
make_ts_tag(t)
|
209
|
-
end
|
210
|
-
|
211
|
-
docker_cli.build(
|
212
|
-
dockerfile: nil,
|
213
|
-
image_url: docker_image_url,
|
214
|
-
tags: [time - 3, time + 6, time - 6, time + 18].map do |t|
|
215
|
-
make_ts_tag(t)
|
216
|
-
end
|
217
|
-
)
|
218
|
-
end
|
219
|
-
|
220
|
-
it { is_expected.to eq(make_ts_tag(time + 18)) }
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe '#previous_tag' do
|
225
|
-
let(:time) { Time.now }
|
226
|
-
let(:current_tag) { make_ts_tag(time) }
|
227
|
-
|
228
|
-
before do
|
229
|
-
docker_remote_client.tags << current_tag
|
230
|
-
docker_cli.build(
|
231
|
-
dockerfile: nil,
|
232
|
-
image_url: docker_image_url,
|
233
|
-
tags: [current_tag]
|
234
|
-
)
|
235
|
-
end
|
236
|
-
|
237
|
-
subject { spec.previous_tag(current_tag) }
|
238
|
-
|
239
|
-
context 'with no previous local or remote tag' do
|
240
|
-
it 'raises an error' do
|
241
|
-
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
context 'with an available previous remote tag' do
|
246
|
-
let(:previous_tag) { make_ts_tag(time - 5) }
|
247
|
-
|
248
|
-
before { docker_remote_client.tags << previous_tag }
|
249
|
-
|
250
|
-
it { is_expected.to eq(previous_tag) }
|
251
|
-
end
|
252
|
-
|
253
|
-
context 'with an available previous local tag' do
|
254
|
-
let(:previous_tag) { make_ts_tag(time - 5) }
|
255
|
-
|
256
|
-
before do
|
257
|
-
docker_cli.build(
|
258
|
-
dockerfile: nil,
|
259
|
-
image_url: docker_image_url,
|
260
|
-
tags: [previous_tag]
|
261
|
-
)
|
262
|
-
end
|
263
|
-
|
264
|
-
it { is_expected.to eq(previous_tag) }
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
159
|
describe '#insert' do
|
269
|
-
subject { spec.
|
160
|
+
subject { spec.image.dockerfile.to_s }
|
270
161
|
|
271
162
|
context 'with a custom class-based build phase' do
|
272
163
|
before do
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# typed: false
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Kuby::Docker::TimestampedImage do
|
5
|
+
let(:dockerfile) { Kuby::Docker::Dockerfile.new }
|
6
|
+
let(:image_url) { docker_image_url }
|
7
|
+
let(:credentials) do
|
8
|
+
Kuby::Docker::Credentials.new do
|
9
|
+
username 'foo'
|
10
|
+
password 'bar'
|
11
|
+
email 'foo@bar.com'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
let(:image) { described_class.new(dockerfile, image_url, credentials) }
|
15
|
+
|
16
|
+
describe '#current_version' do
|
17
|
+
let(:tag) { make_ts_tag(Time.now) }
|
18
|
+
|
19
|
+
subject { image.current_version&.main_tag }
|
20
|
+
|
21
|
+
context 'with no local or remote tags' do
|
22
|
+
it 'raises an error' do
|
23
|
+
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with an available remote tag' do
|
28
|
+
before { docker_remote_client.tags << tag }
|
29
|
+
|
30
|
+
it { is_expected.to eq(tag) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with an available local tag' do
|
34
|
+
before do
|
35
|
+
docker_cli.build(
|
36
|
+
dockerfile: nil,
|
37
|
+
image_url: docker_image_url,
|
38
|
+
tags: [tag]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it { is_expected.to eq(tag) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with multiple remote tags' do
|
46
|
+
let(:time) { Time.now }
|
47
|
+
|
48
|
+
before do
|
49
|
+
docker_remote_client.tags +=
|
50
|
+
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
51
|
+
make_ts_tag(t)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it { is_expected.to eq(make_ts_tag(time + 15)) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with multiple local and remote tags' do
|
59
|
+
let(:time) { Time.now }
|
60
|
+
|
61
|
+
before do
|
62
|
+
docker_remote_client.tags +=
|
63
|
+
[time - 5, time + 10, time - 10, time + 15].map do |t|
|
64
|
+
make_ts_tag(t)
|
65
|
+
end
|
66
|
+
|
67
|
+
docker_cli.build(
|
68
|
+
dockerfile: nil,
|
69
|
+
image_url: docker_image_url,
|
70
|
+
tags: [time - 3, time + 6, time - 6, time + 18].map do |t|
|
71
|
+
make_ts_tag(t)
|
72
|
+
end
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it { is_expected.to eq(make_ts_tag(time + 18)) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#previous_version' do
|
81
|
+
let(:time) { Time.now }
|
82
|
+
let(:current_tag) { make_ts_tag(time) }
|
83
|
+
|
84
|
+
before do
|
85
|
+
docker_remote_client.tags << current_tag
|
86
|
+
docker_cli.build(
|
87
|
+
dockerfile: nil,
|
88
|
+
image_url: docker_image_url,
|
89
|
+
tags: [current_tag]
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
subject { image.previous_version(current_tag)&.main_tag }
|
94
|
+
|
95
|
+
context 'with no previous local or remote tag' do
|
96
|
+
it 'raises an error' do
|
97
|
+
expect { subject }.to raise_error(Kuby::Docker::MissingTagError)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'with an available previous remote tag' do
|
102
|
+
let(:previous_tag) { make_ts_tag(time - 5) }
|
103
|
+
|
104
|
+
before { docker_remote_client.tags << previous_tag }
|
105
|
+
|
106
|
+
it { is_expected.to eq(previous_tag) }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with an available previous local tag' do
|
110
|
+
let(:previous_tag) { make_ts_tag(time - 5) }
|
111
|
+
|
112
|
+
before do
|
113
|
+
docker_cli.build(
|
114
|
+
dockerfile: nil,
|
115
|
+
image_url: docker_image_url,
|
116
|
+
tags: [previous_tag]
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
it { is_expected.to eq(previous_tag) }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -71,24 +71,23 @@ module SpecHelpers
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
75
|
-
environment(:development) do
|
76
|
-
kubernetes do
|
77
|
-
configure_plugin(:rails_app) do
|
78
|
-
root File.expand_path(File.join(*%w(. dummy)), __dir__)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
74
|
end
|
83
75
|
|
84
76
|
docker = definition.environment.docker
|
85
77
|
|
86
|
-
docker.instance_variable_set(:@remote_client, docker_remote_client)
|
87
|
-
docker.instance_variable_set(:@cli, docker_cli)
|
88
|
-
|
89
78
|
definition
|
90
79
|
end
|
91
80
|
|
81
|
+
before do
|
82
|
+
allow_any_instance_of(Kuby::Docker::TimestampedImage).to(
|
83
|
+
receive(:remote_client).and_return(docker_remote_client)
|
84
|
+
)
|
85
|
+
|
86
|
+
allow_any_instance_of(Kuby::Docker::Image).to(
|
87
|
+
receive(:docker_cli).and_return(docker_cli)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
92
91
|
def make_ts_tag(time)
|
93
92
|
Kuby::Docker::TimestampTag.new(time).to_s
|
94
93
|
end
|
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.12.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-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.6'
|
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: '0.
|
40
|
+
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,25 +219,24 @@ files:
|
|
219
219
|
- lib/kuby/cli_base.rb
|
220
220
|
- lib/kuby/commands.rb
|
221
221
|
- lib/kuby/definition.rb
|
222
|
-
- lib/kuby/dev_setup.rb
|
223
222
|
- lib/kuby/docker.rb
|
224
223
|
- lib/kuby/docker/alpine.rb
|
224
|
+
- lib/kuby/docker/app_image.rb
|
225
225
|
- lib/kuby/docker/assets_phase.rb
|
226
226
|
- lib/kuby/docker/bundler_phase.rb
|
227
227
|
- lib/kuby/docker/cli.rb
|
228
228
|
- lib/kuby/docker/copy_phase.rb
|
229
229
|
- lib/kuby/docker/credentials.rb
|
230
230
|
- lib/kuby/docker/debian.rb
|
231
|
-
- lib/kuby/docker/dev_spec.rb
|
232
231
|
- lib/kuby/docker/distro.rb
|
233
232
|
- lib/kuby/docker/docker_uri.rb
|
234
233
|
- lib/kuby/docker/dockerfile.rb
|
235
234
|
- lib/kuby/docker/errors.rb
|
235
|
+
- lib/kuby/docker/image.rb
|
236
236
|
- lib/kuby/docker/inline_layer.rb
|
237
237
|
- lib/kuby/docker/layer.rb
|
238
238
|
- lib/kuby/docker/layer_stack.rb
|
239
239
|
- lib/kuby/docker/local_tags.rb
|
240
|
-
- lib/kuby/docker/metadata.rb
|
241
240
|
- lib/kuby/docker/package_list.rb
|
242
241
|
- lib/kuby/docker/package_phase.rb
|
243
242
|
- lib/kuby/docker/packages.rb
|
@@ -249,8 +248,8 @@ files:
|
|
249
248
|
- lib/kuby/docker/remote_tags.rb
|
250
249
|
- lib/kuby/docker/setup_phase.rb
|
251
250
|
- lib/kuby/docker/spec.rb
|
252
|
-
- lib/kuby/docker/tags.rb
|
253
251
|
- lib/kuby/docker/timestamp_tag.rb
|
252
|
+
- lib/kuby/docker/timestamped_image.rb
|
254
253
|
- lib/kuby/docker/webserver_phase.rb
|
255
254
|
- lib/kuby/docker/yarn_phase.rb
|
256
255
|
- lib/kuby/environment.rb
|
@@ -274,6 +273,7 @@ files:
|
|
274
273
|
- lib/kuby/plugins/rails_app.rb
|
275
274
|
- lib/kuby/plugins/rails_app/asset_copy_task.rb
|
276
275
|
- lib/kuby/plugins/rails_app/assets.rb
|
276
|
+
- lib/kuby/plugins/rails_app/assets_image.rb
|
277
277
|
- lib/kuby/plugins/rails_app/database.rb
|
278
278
|
- lib/kuby/plugins/rails_app/generators/kuby.rb
|
279
279
|
- lib/kuby/plugins/rails_app/mysql.rb
|
@@ -282,14 +282,13 @@ files:
|
|
282
282
|
- lib/kuby/plugins/rails_app/rewrite_db_config.rb
|
283
283
|
- lib/kuby/plugins/rails_app/sqlite.rb
|
284
284
|
- lib/kuby/plugins/rails_app/tasks.rake
|
285
|
-
- lib/kuby/rails_commands.rb
|
286
285
|
- lib/kuby/railtie.rb
|
287
286
|
- lib/kuby/tasks.rb
|
288
287
|
- lib/kuby/trailing_hash.rb
|
289
288
|
- lib/kuby/version.rb
|
290
|
-
- spec/docker/metadata_spec.rb
|
291
289
|
- spec/docker/spec_spec.rb
|
292
290
|
- spec/docker/timestamp_tag_spec.rb
|
291
|
+
- spec/docker/timestamped_image_spec.rb
|
293
292
|
- spec/dummy/Gemfile
|
294
293
|
- spec/dummy/Gemfile.lock
|
295
294
|
- spec/dummy/README.md
|