kuby-core 0.10.1 → 0.11.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 +11 -0
- data/Gemfile +1 -0
- data/README.md +4 -2
- data/kuby-core.gemspec +2 -1
- data/lib/kuby-core.rb +1 -0
- data/lib/kuby.rb +7 -0
- data/lib/kuby/basic_logger.rb +1 -0
- data/lib/kuby/cli_base.rb +1 -0
- data/lib/kuby/commands.rb +1 -0
- data/lib/kuby/definition.rb +1 -0
- data/lib/kuby/dev_setup.rb +1 -0
- data/lib/kuby/docker.rb +3 -0
- data/lib/kuby/docker/alpine.rb +16 -12
- data/lib/kuby/docker/assets_phase.rb +5 -0
- data/lib/kuby/docker/bundler_phase.rb +36 -2
- data/lib/kuby/docker/cli.rb +36 -2
- data/lib/kuby/docker/copy_phase.rb +11 -3
- data/lib/kuby/docker/credentials.rb +1 -0
- data/lib/kuby/docker/debian.rb +14 -10
- data/lib/kuby/docker/dev_spec.rb +82 -18
- data/lib/kuby/docker/distro.rb +43 -0
- data/lib/kuby/docker/dockerfile.rb +66 -18
- data/lib/kuby/docker/errors.rb +8 -0
- data/lib/kuby/docker/inline_layer.rb +7 -0
- data/lib/kuby/docker/layer.rb +11 -0
- data/lib/kuby/docker/layer_stack.rb +43 -6
- data/lib/kuby/docker/local_tags.rb +23 -2
- data/lib/kuby/docker/metadata.rb +35 -7
- data/lib/kuby/docker/package_list.rb +22 -3
- data/lib/kuby/docker/package_phase.rb +25 -5
- data/lib/kuby/docker/packages.rb +1 -0
- data/lib/kuby/docker/packages/managed_package.rb +20 -2
- data/lib/kuby/docker/packages/nodejs.rb +8 -0
- data/lib/kuby/docker/packages/package.rb +15 -1
- data/lib/kuby/docker/packages/simple_managed_package.rb +10 -1
- data/lib/kuby/docker/packages/yarn.rb +14 -0
- data/lib/kuby/docker/remote_tags.rb +21 -2
- data/lib/kuby/docker/setup_phase.rb +35 -4
- data/lib/kuby/docker/spec.rb +89 -13
- data/lib/kuby/docker/tags.rb +37 -2
- data/lib/kuby/docker/timestamp_tag.rb +14 -2
- data/lib/kuby/docker/webserver_phase.rb +40 -5
- data/lib/kuby/docker/yarn_phase.rb +5 -0
- data/lib/kuby/environment.rb +4 -0
- data/lib/kuby/kubernetes.rb +1 -0
- data/lib/kuby/kubernetes/deploy_task.rb +1 -0
- data/lib/kuby/kubernetes/deployer.rb +1 -0
- data/lib/kuby/kubernetes/docker_config.rb +1 -0
- data/lib/kuby/kubernetes/docker_desktop_provider.rb +1 -0
- data/lib/kuby/kubernetes/errors.rb +1 -0
- data/lib/kuby/kubernetes/manifest.rb +1 -0
- data/lib/kuby/kubernetes/provider.rb +1 -0
- data/lib/kuby/kubernetes/registry_secret.rb +1 -0
- data/lib/kuby/kubernetes/spec.rb +1 -0
- data/lib/kuby/middleware.rb +1 -0
- data/lib/kuby/middleware/health_check.rb +1 -0
- data/lib/kuby/plugin.rb +1 -0
- data/lib/kuby/plugin_registry.rb +1 -0
- data/lib/kuby/plugins.rb +1 -0
- data/lib/kuby/plugins/nginx_ingress.rb +1 -0
- data/lib/kuby/plugins/rails_app.rb +1 -0
- data/lib/kuby/plugins/rails_app/asset_copy_task.rb +1 -0
- data/lib/kuby/plugins/rails_app/assets.rb +1 -0
- data/lib/kuby/plugins/rails_app/database.rb +9 -7
- data/lib/kuby/plugins/rails_app/generators/kuby.rb +43 -40
- data/lib/kuby/plugins/rails_app/mysql.rb +1 -0
- data/lib/kuby/plugins/rails_app/plugin.rb +10 -5
- data/lib/kuby/plugins/rails_app/postgres.rb +1 -0
- data/lib/kuby/plugins/rails_app/rewrite_db_config.rb +1 -0
- data/lib/kuby/plugins/rails_app/sqlite.rb +1 -0
- data/lib/kuby/rails_commands.rb +1 -0
- data/lib/kuby/railtie.rb +1 -0
- data/lib/kuby/tasks.rb +1 -0
- data/lib/kuby/trailing_hash.rb +5 -3
- data/lib/kuby/version.rb +3 -1
- data/spec/docker/metadata_spec.rb +1 -0
- data/spec/docker/spec_spec.rb +37 -0
- data/spec/docker/timestamp_tag_spec.rb +1 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +1 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/jobs/application_job.rb +1 -0
- data/spec/dummy/app/mailers/application_mailer.rb +1 -0
- data/spec/dummy/app/models/application_record.rb +1 -0
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +1 -0
- data/spec/dummy/config/initializers/assets.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +1 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +1 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/puma.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/config/spring.rb +1 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/test/application_system_test_case.rb +1 -0
- data/spec/dummy/test/channels/application_cable/connection_test.rb +1 -0
- data/spec/dummy/test/test_helper.rb +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/docker/fake_cli.rb +1 -0
- data/spec/support/docker/remote/fake_client.rb +1 -0
- data/spec/trailing_hash_spec.rb +2 -0
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e975e73abc299262e996d4bc336f951633d993c8fe56ce997543fb442abe57
|
4
|
+
data.tar.gz: 1a662d6ff200ecf2b9b8fdd7446d0936329599d940afd06800166537bf82005e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d01ba9e76b0bc79c0d22c63ab65a4edbec0f35add876935233402ae6c96077adeb1b91cef3003858f0534441b1939beae31872860ba453ef3b9ef13aa84d76
|
7
|
+
data.tar.gz: bb75588789e02dc6bf4135ab59fb401d1ce8e07d8169460ff86282128d1ea610e01de01c44e564c4a9196959a9f6975640f0c14407bd3d02e8257499b0723099
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.11.0
|
2
|
+
* Defer evaluation of database config until after Kuby has been configured.
|
3
|
+
- The issue that prompted this was that the `database` block was being evaluated before the Rails root had been set via `root`. Kuby couldn't find database.yml in a non-standard location and blew up with an error.
|
4
|
+
* Fix tests broken in 0.10.1.
|
5
|
+
* Set up Travis CI builds.
|
6
|
+
* Add a few tests for custom build phases.
|
7
|
+
* Add the `Environment#configured?` method that will return `true` if Kuby has been configured and `false` if configuration hasn't happened or is in progress.
|
8
|
+
* Add sorbet typedefs for some classes.
|
9
|
+
* Fix issue in Rails generator (hadn't been updated with new `environment` block).
|
10
|
+
* Add kuby-core.rb so Bundler setup works for Kuby without having to add a Rails initializer.
|
11
|
+
|
1
12
|
## 0.10.1
|
2
13
|
* Fix bug causing some `rails` and `rake` commands to not be executed.
|
3
14
|
* Fix issue restricting Docker CLI output.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## Kuby
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.com/getkuby/kuby-core.svg?branch=master)](https://travis-ci.com/getkuby/kuby-core)
|
4
|
+
|
3
5
|
Deploy your Rails app the easy way.
|
4
6
|
|
5
7
|
## What is Kuby?
|
@@ -20,11 +22,11 @@ Kuby embraces the same convention-over-configuration approach that Rails does. I
|
|
20
22
|
|
21
23
|
## Getting Started
|
22
24
|
|
23
|
-
See the [Quick Start Guide](https://
|
25
|
+
See the [Quick Start Guide](https://getkuby.io/docs)
|
24
26
|
|
25
27
|
## More Info
|
26
28
|
|
27
|
-
|
29
|
+
Check out [getkuby.io](https://getkuby.io).
|
28
30
|
|
29
31
|
## Running Tests
|
30
32
|
|
data/kuby-core.gemspec
CHANGED
@@ -20,11 +20,12 @@ Gem::Specification.new do |s|
|
|
20
20
|
# See: https://github.com/Shopify/krane/blob/master/CHANGELOG.md#114
|
21
21
|
s.add_dependency 'krane', '>= 1.1.4', '< 2.0'
|
22
22
|
s.add_dependency 'kuby-cert-manager', '>= 0.3'
|
23
|
-
s.add_dependency 'kube-dsl', '~> 0.
|
23
|
+
s.add_dependency 'kube-dsl', '~> 0.4'
|
24
24
|
s.add_dependency 'kuby-kube-db', '>= 0.6'
|
25
25
|
s.add_dependency 'kubernetes-cli', '~> 0.3'
|
26
26
|
s.add_dependency 'railties', '>= 5.1'
|
27
27
|
s.add_dependency 'rouge', '~> 3.0'
|
28
|
+
s.add_dependency 'sorbet-runtime-stub', '~> 0.2'
|
28
29
|
|
29
30
|
s.add_development_dependency 'rspec'
|
30
31
|
|
data/lib/kuby-core.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'kuby'
|
data/lib/kuby.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
require 'sorbet-runtime-stub'
|
1
4
|
require 'kuby/railtie'
|
2
5
|
|
3
6
|
begin
|
@@ -69,6 +72,10 @@ module Kuby
|
|
69
72
|
env.kubernetes.after_configuration
|
70
73
|
end
|
71
74
|
|
75
|
+
@definition.environments.each do |_, env|
|
76
|
+
env.configured = true
|
77
|
+
end
|
78
|
+
|
72
79
|
@definition
|
73
80
|
end
|
74
81
|
|
data/lib/kuby/basic_logger.rb
CHANGED
data/lib/kuby/cli_base.rb
CHANGED
data/lib/kuby/commands.rb
CHANGED
data/lib/kuby/definition.rb
CHANGED
data/lib/kuby/dev_setup.rb
CHANGED
data/lib/kuby/docker.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
require 'kuby/docker/errors'
|
2
4
|
|
3
5
|
module Kuby
|
@@ -10,6 +12,7 @@ module Kuby
|
|
10
12
|
autoload :Credentials, 'kuby/docker/credentials'
|
11
13
|
autoload :Debian, 'kuby/docker/debian'
|
12
14
|
autoload :DevSpec, 'kuby/docker/dev_spec'
|
15
|
+
autoload :Distro, 'kuby/docker/distro'
|
13
16
|
autoload :Dockerfile, 'kuby/docker/dockerfile'
|
14
17
|
autoload :InlineLayer, 'kuby/docker/inline_layer'
|
15
18
|
autoload :Layer, 'kuby/docker/layer'
|
data/lib/kuby/docker/alpine.rb
CHANGED
@@ -1,40 +1,43 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
module Kuby
|
2
4
|
module Docker
|
3
|
-
class Alpine
|
4
|
-
SHELL_EXE = '/bin/sh'.freeze
|
5
|
+
class Alpine < Distro
|
6
|
+
SHELL_EXE = T.let('/bin/sh'.freeze, String)
|
5
7
|
|
6
|
-
DEFAULT_PACKAGES = [
|
7
|
-
[:ca_certificates],
|
8
|
+
DEFAULT_PACKAGES = T.let([
|
9
|
+
[:ca_certificates, nil],
|
8
10
|
[:nodejs, '12.14.1'],
|
9
11
|
[:yarn, '1.21.1'],
|
10
|
-
[:c_toolchain],
|
11
|
-
[:tzdata]
|
12
|
-
].freeze
|
12
|
+
[:c_toolchain, nil],
|
13
|
+
[:tzdata, nil]
|
14
|
+
].freeze, T::Array[[Symbol, T.nilable(String)]])
|
13
15
|
|
16
|
+
sig { returns(Layer) }
|
14
17
|
attr_reader :phase
|
15
18
|
|
16
|
-
|
17
|
-
@phase = phase
|
18
|
-
end
|
19
|
-
|
19
|
+
sig { override.params(packages: T::Array[Distro::PackageImpl], into: Dockerfile).void }
|
20
20
|
def install(packages, into:)
|
21
21
|
dockerfile = into
|
22
22
|
install_managed(packages, dockerfile)
|
23
23
|
install_unmanaged(packages, dockerfile)
|
24
24
|
end
|
25
25
|
|
26
|
+
sig { override.returns(T::Array[[Symbol, T.nilable(String)]]) }
|
26
27
|
def default_packages
|
27
28
|
DEFAULT_PACKAGES
|
28
29
|
end
|
29
30
|
|
31
|
+
sig { override.returns(String) }
|
30
32
|
def shell_exe
|
31
33
|
SHELL_EXE
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
35
37
|
|
38
|
+
sig { params(packages: T::Array[Distro::PackageImpl], dockerfile: Dockerfile).void }
|
36
39
|
def install_managed(packages, dockerfile)
|
37
|
-
pkgs = packages.select(&:managed?)
|
40
|
+
pkgs = T.cast(packages.select(&:managed?), T::Array[Distro::ManagedPackageImpl])
|
38
41
|
|
39
42
|
unless pkgs.empty?
|
40
43
|
package_names = pkgs.map { |pkg| pkg.package_name_for(:alpine) }
|
@@ -44,6 +47,7 @@ module Kuby
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
50
|
+
sig { params(packages: T::Array[Distro::PackageImpl], dockerfile: Dockerfile).void }
|
47
51
|
def install_unmanaged(packages, dockerfile)
|
48
52
|
packages
|
49
53
|
.reject(&:managed?)
|
@@ -1,12 +1,44 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
|
3
5
|
module Kuby
|
4
6
|
module Docker
|
5
7
|
class BundlerPhase < Layer
|
6
|
-
|
8
|
+
extend T::Sig
|
9
|
+
|
10
|
+
DEFAULT_WITHOUT = T.let(
|
11
|
+
['development', 'test', 'deploy'].freeze, T::Array[String]
|
12
|
+
)
|
13
|
+
|
14
|
+
sig { returns(T.nilable(String)) }
|
15
|
+
attr_reader :version
|
16
|
+
|
17
|
+
sig { params(version: String).void }
|
18
|
+
attr_writer :version
|
19
|
+
|
20
|
+
sig { returns(T.nilable(String)) }
|
21
|
+
attr_reader :gemfile
|
7
22
|
|
8
|
-
|
23
|
+
sig { params(gemfile: String).void }
|
24
|
+
attr_writer :gemfile
|
25
|
+
|
26
|
+
sig { returns(T.nilable(T::Array[String])) }
|
27
|
+
attr_reader :without
|
28
|
+
|
29
|
+
sig { params(without: T::Array[String]).void }
|
30
|
+
attr_writer :without
|
31
|
+
|
32
|
+
sig { params(environment: Environment).void }
|
33
|
+
def initialize(environment)
|
34
|
+
super
|
35
|
+
|
36
|
+
@version = T.let(@version, T.nilable(String))
|
37
|
+
@gemfile = T.let(@gemfile, T.nilable(String))
|
38
|
+
@without = T.let(@without, T.nilable(T::Array[String]))
|
39
|
+
end
|
9
40
|
|
41
|
+
sig { override.params(dockerfile: Dockerfile).void }
|
10
42
|
def apply_to(dockerfile)
|
11
43
|
gf = gemfile || default_gemfile
|
12
44
|
lf = "#{gf}.lock"
|
@@ -41,10 +73,12 @@ module Kuby
|
|
41
73
|
|
42
74
|
private
|
43
75
|
|
76
|
+
sig { returns(String) }
|
44
77
|
def default_version
|
45
78
|
Bundler::VERSION
|
46
79
|
end
|
47
80
|
|
81
|
+
sig { returns(String) }
|
48
82
|
def default_gemfile
|
49
83
|
Bundler
|
50
84
|
.definition
|
data/lib/kuby/docker/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'open3'
|
3
5
|
require 'shellwords'
|
@@ -5,22 +7,29 @@ require 'shellwords'
|
|
5
7
|
module Kuby
|
6
8
|
module Docker
|
7
9
|
class CLI < CLIBase
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
sig { returns(String) }
|
8
13
|
attr_reader :executable
|
9
14
|
|
15
|
+
sig { params(executable: T.nilable(String)).void }
|
10
16
|
def initialize(executable = nil)
|
11
|
-
@executable = executable || `which docker`.strip
|
17
|
+
@executable = T.let(executable || `which docker`.strip, String)
|
12
18
|
end
|
13
19
|
|
20
|
+
sig { returns(T.nilable(String)) }
|
14
21
|
def config_file
|
15
22
|
if File.exist?(default_config_file)
|
16
23
|
default_config_file
|
17
24
|
end
|
18
25
|
end
|
19
26
|
|
27
|
+
sig { returns(String) }
|
20
28
|
def default_config_file
|
21
29
|
File.join(Dir.home, '.docker', 'config.json')
|
22
30
|
end
|
23
31
|
|
32
|
+
sig { params(url: String, username: String, password: String).void }
|
24
33
|
def login(url:, username:, password:)
|
25
34
|
cmd = [
|
26
35
|
executable, 'login', url, '--username', username, '--password-stdin'
|
@@ -36,13 +45,23 @@ module Kuby
|
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
48
|
+
sig { returns(T::Array[String]) }
|
39
49
|
def auths
|
40
50
|
return [] unless config_file
|
41
51
|
|
42
|
-
config = JSON.parse(File.read(config_file))
|
52
|
+
config = JSON.parse(File.read(T.must(config_file)))
|
43
53
|
config.fetch('auths', {}).keys
|
44
54
|
end
|
45
55
|
|
56
|
+
sig {
|
57
|
+
params(
|
58
|
+
dockerfile: Dockerfile,
|
59
|
+
image_url: String,
|
60
|
+
tags: T::Array[String],
|
61
|
+
build_args: T::Hash[T.any(Symbol, String), String]
|
62
|
+
)
|
63
|
+
.void
|
64
|
+
}
|
46
65
|
def build(dockerfile:, image_url:, tags:, build_args: {})
|
47
66
|
cmd = [
|
48
67
|
executable, 'build',
|
@@ -63,6 +82,15 @@ module Kuby
|
|
63
82
|
end
|
64
83
|
end
|
65
84
|
|
85
|
+
sig {
|
86
|
+
params(
|
87
|
+
image_url: String,
|
88
|
+
tag: String,
|
89
|
+
env: T::Hash[T.any(Symbol, String), String],
|
90
|
+
ports: T::Array[T.any(String, Integer)]
|
91
|
+
)
|
92
|
+
.void
|
93
|
+
}
|
66
94
|
def run(image_url:, tag: 'latest', env: {}, ports: [])
|
67
95
|
cmd = [
|
68
96
|
executable, 'run',
|
@@ -76,6 +104,7 @@ module Kuby
|
|
76
104
|
execc(cmd)
|
77
105
|
end
|
78
106
|
|
107
|
+
sig { params(image_url: String).returns(T::Array[T::Hash[Symbol, String]]) }
|
79
108
|
def images(image_url)
|
80
109
|
cmd = [
|
81
110
|
executable, 'images', image_url,
|
@@ -89,6 +118,7 @@ module Kuby
|
|
89
118
|
end
|
90
119
|
end
|
91
120
|
|
121
|
+
sig { params(image_url: String, tag: String).void }
|
92
122
|
def push(image_url, tag)
|
93
123
|
systemm([
|
94
124
|
executable, 'push', "#{image_url}:#{tag}"
|
@@ -100,6 +130,7 @@ module Kuby
|
|
100
130
|
end
|
101
131
|
end
|
102
132
|
|
133
|
+
sig { params(image_url: String, tag: String).void }
|
103
134
|
def pull(image_url, tag)
|
104
135
|
systemm([
|
105
136
|
executable, 'pull', "#{image_url}:#{tag}"
|
@@ -111,14 +142,17 @@ module Kuby
|
|
111
142
|
end
|
112
143
|
end
|
113
144
|
|
145
|
+
sig { returns(Symbol) }
|
114
146
|
def status_key
|
115
147
|
:kuby_docker_cli_last_status
|
116
148
|
end
|
117
149
|
|
150
|
+
sig { returns(Symbol) }
|
118
151
|
def stdout_key
|
119
152
|
:kuby_docker_stdout
|
120
153
|
end
|
121
154
|
|
155
|
+
sig { returns(Symbol) }
|
122
156
|
def stderr_key
|
123
157
|
:kuby_docker_stderr
|
124
158
|
end
|
@@ -1,19 +1,27 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
module Kuby
|
2
4
|
module Docker
|
3
5
|
class CopyPhase < Layer
|
4
|
-
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
DEFAULT_PATHS = T.let(['./'].freeze, T::Array[String])
|
5
9
|
|
10
|
+
sig { returns(T::Array[String]) }
|
6
11
|
attr_reader :paths
|
7
12
|
|
8
|
-
|
13
|
+
sig { params(environment: Environment).void }
|
14
|
+
def initialize(environment)
|
9
15
|
super
|
10
|
-
@paths = []
|
16
|
+
@paths = T.let([], T::Array[String])
|
11
17
|
end
|
12
18
|
|
19
|
+
sig { params(path: String).void }
|
13
20
|
def <<(path)
|
14
21
|
paths << path
|
15
22
|
end
|
16
23
|
|
24
|
+
sig { params(dockerfile: Dockerfile).void }
|
17
25
|
def apply_to(dockerfile)
|
18
26
|
to_copy = paths.empty? ? DEFAULT_PATHS : paths
|
19
27
|
to_copy.each { |path| dockerfile.copy(path, '.') }
|
data/lib/kuby/docker/debian.rb
CHANGED
@@ -1,38 +1,41 @@
|
|
1
|
+
# typed: strict
|
2
|
+
|
1
3
|
module Kuby
|
2
4
|
module Docker
|
3
|
-
class Debian
|
4
|
-
SHELL_EXE = '/bin/bash'
|
5
|
+
class Debian < Distro
|
6
|
+
SHELL_EXE = T.let('/bin/bash'.freeze, String)
|
5
7
|
|
6
|
-
DEFAULT_PACKAGES = [
|
7
|
-
[:ca_certificates],
|
8
|
+
DEFAULT_PACKAGES = T.let([
|
9
|
+
[:ca_certificates, nil],
|
8
10
|
[:nodejs, '12.14.1'],
|
9
11
|
[:yarn, '1.21.1']
|
10
|
-
].freeze
|
12
|
+
].freeze, T::Array[[Symbol, T.nilable(String)]])
|
11
13
|
|
14
|
+
sig { returns(Layer) }
|
12
15
|
attr_reader :phase
|
13
16
|
|
14
|
-
|
15
|
-
@phase = phase
|
16
|
-
end
|
17
|
-
|
17
|
+
sig { override.params(packages: T::Array[Distro::PackageImpl], into: Dockerfile).void }
|
18
18
|
def install(packages, into:)
|
19
19
|
dockerfile = into
|
20
20
|
install_managed(packages, dockerfile)
|
21
21
|
install_unmanaged(packages, dockerfile)
|
22
22
|
end
|
23
23
|
|
24
|
+
sig { override.returns(T::Array[[Symbol, T.nilable(String)]]) }
|
24
25
|
def default_packages
|
25
26
|
DEFAULT_PACKAGES
|
26
27
|
end
|
27
28
|
|
29
|
+
sig { override.returns(String) }
|
28
30
|
def shell_exe
|
29
31
|
SHELL_EXE
|
30
32
|
end
|
31
33
|
|
32
34
|
private
|
33
35
|
|
36
|
+
sig { params(packages: T::Array[Distro::PackageImpl], dockerfile: Dockerfile).void }
|
34
37
|
def install_managed(packages, dockerfile)
|
35
|
-
pkgs = packages.select(&:managed?)
|
38
|
+
pkgs = T.cast(packages.select(&:managed?), T::Array[Distro::ManagedPackageImpl])
|
36
39
|
|
37
40
|
pkg_cmd = <<~CMD.strip
|
38
41
|
apt-get update -qq && \\
|
@@ -49,6 +52,7 @@ module Kuby
|
|
49
52
|
dockerfile.run(pkg_cmd)
|
50
53
|
end
|
51
54
|
|
55
|
+
sig { params(packages: T::Array[Distro::PackageImpl], dockerfile: Dockerfile).void }
|
52
56
|
def install_unmanaged(packages, dockerfile)
|
53
57
|
packages
|
54
58
|
.reject(&:managed?)
|