kuby-core 0.17.0 → 0.18.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 +44 -0
- data/Gemfile +6 -2
- data/Rakefile +5 -3
- data/bin/tapioca +29 -0
- data/kuby-core.gemspec +9 -11
- data/lib/kuby/basic_logger.rb +34 -34
- data/lib/kuby/cli_base.rb +43 -43
- data/lib/kuby/commands.rb +94 -11
- data/lib/kuby/definition.rb +12 -12
- data/lib/kuby/dependable.rb +20 -0
- data/lib/kuby/dependency.rb +14 -0
- data/lib/kuby/docker/alpine.rb +10 -10
- data/lib/kuby/docker/app_image.rb +11 -11
- data/lib/kuby/docker/app_phase.rb +36 -0
- data/lib/kuby/docker/assets_phase.rb +2 -2
- data/lib/kuby/docker/bundler_phase.rb +42 -40
- data/lib/kuby/docker/cli.rb +71 -43
- data/lib/kuby/docker/copy_phase.rb +7 -7
- data/lib/kuby/docker/credentials.rb +1 -0
- data/lib/kuby/docker/debian.rb +10 -10
- data/lib/kuby/docker/distro.rb +13 -13
- data/lib/kuby/docker/docker_uri.rb +20 -20
- data/lib/kuby/docker/dockerfile.rb +48 -39
- data/lib/kuby/docker/image.rb +66 -54
- data/lib/kuby/docker/inline_layer.rb +4 -4
- data/lib/kuby/docker/layer.rb +6 -6
- data/lib/kuby/docker/layer_stack.rb +35 -35
- data/lib/kuby/docker/local_tags.rb +16 -16
- data/lib/kuby/docker/package_list.rb +16 -16
- data/lib/kuby/docker/package_phase.rb +16 -16
- data/lib/kuby/docker/packages/managed_package.rb +13 -13
- data/lib/kuby/docker/packages/nodejs.rb +5 -5
- data/lib/kuby/docker/packages/package.rb +8 -8
- data/lib/kuby/docker/packages/simple_managed_package.rb +7 -7
- data/lib/kuby/docker/packages/yarn.rb +6 -6
- data/lib/kuby/docker/remote_tags.rb +16 -16
- data/lib/kuby/docker/setup_phase.rb +18 -20
- data/lib/kuby/docker/spec.rb +93 -72
- data/lib/kuby/docker/timestamp_tag.rb +16 -11
- data/lib/kuby/docker/timestamped_image.rb +59 -40
- data/lib/kuby/docker/webserver_phase.rb +20 -20
- data/lib/kuby/docker/yarn_phase.rb +29 -5
- data/lib/kuby/docker.rb +2 -1
- data/lib/kuby/kubernetes/bare_metal_provider.rb +9 -9
- data/lib/kuby/kubernetes/deployer.rb +22 -10
- data/lib/kuby/kubernetes/docker_config.rb +1 -0
- data/lib/kuby/kubernetes/provider.rb +1 -0
- data/lib/kuby/kubernetes/spec.rb +47 -7
- data/lib/kuby/plugin.rb +22 -1
- data/lib/kuby/plugins/nginx_ingress.rb +8 -6
- data/lib/kuby/plugins/rails_app/assets.rb +16 -4
- data/lib/kuby/plugins/rails_app/assets_image.rb +17 -8
- data/lib/kuby/plugins/rails_app/crdb/plugin.rb +473 -0
- data/lib/kuby/plugins/rails_app/crdb.rb +9 -0
- data/lib/kuby/plugins/rails_app/database.rb +12 -8
- data/lib/kuby/plugins/rails_app/generators/kuby.rb +17 -16
- data/lib/kuby/plugins/rails_app/plugin.rb +29 -18
- data/lib/kuby/plugins/rails_app/sqlite.rb +7 -3
- data/lib/kuby/plugins/rails_app/tasks.rake +25 -12
- data/lib/kuby/plugins/rails_app.rb +1 -0
- data/lib/kuby/plugins/system.rb +16 -0
- data/lib/kuby/plugins.rb +1 -0
- data/lib/kuby/railtie.rb +31 -1
- data/lib/kuby/tasks.rb +72 -5
- data/lib/kuby/trailing_hash.rb +2 -2
- data/lib/kuby/utils/sem_ver/constraint.rb +68 -0
- data/lib/kuby/utils/sem_ver/constraint_set.rb +25 -0
- data/lib/kuby/utils/sem_ver/version.rb +49 -0
- data/lib/kuby/utils/sem_ver.rb +17 -0
- data/lib/kuby/utils/which.rb +65 -0
- data/lib/kuby/utils.rb +7 -1
- data/lib/kuby/version.rb +1 -1
- data/lib/kuby.rb +37 -2
- data/rbi/kuby-core.rbi +2128 -0
- data/spec/docker/spec_spec.rb +50 -26
- data/spec/dummy/app/channels/application_cable/channel.rb +2 -1
- data/spec/dummy/app/channels/application_cable/connection.rb +2 -1
- data/spec/dummy/app/controllers/application_controller.rb +2 -1
- data/spec/dummy/app/jobs/application_job.rb +2 -1
- data/spec/dummy/app/mailers/application_mailer.rb +2 -1
- data/spec/dummy/app/models/application_record.rb +2 -1
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/test/application_system_test_case.rb +2 -1
- data/spec/dummy/test/channels/application_cable/connection_test.rb +2 -1
- data/spec/spec_helper.rb +13 -1
- metadata +44 -39
- data/lib/kuby/plugins/rails_app/mysql.rb +0 -158
- data/lib/kuby/plugins/rails_app/postgres.rb +0 -163
@@ -3,44 +3,44 @@
|
|
3
3
|
module Kuby
|
4
4
|
module Docker
|
5
5
|
class LayerStack
|
6
|
-
extend T::Sig
|
7
|
-
extend T::Generic
|
6
|
+
# extend T::Sig
|
7
|
+
# extend T::Generic
|
8
8
|
|
9
|
-
Elem = type_member
|
9
|
+
# Elem = type_member { { fixed: Kuby::Docker::Layer } }
|
10
10
|
|
11
11
|
include Enumerable
|
12
12
|
|
13
|
-
sig { returns(T::Array[Symbol]) }
|
13
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[Symbol]) }
|
14
14
|
attr_reader :stack
|
15
15
|
|
16
|
-
sig { returns(T::Hash[Symbol, Layer]) }
|
16
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, Kuby::Docker::Layer]) }
|
17
17
|
attr_reader :layers
|
18
18
|
|
19
|
-
sig { void }
|
19
|
+
# T::Sig::WithoutRuntime.sig { void }
|
20
20
|
def initialize
|
21
|
-
@stack =
|
22
|
-
@layers =
|
21
|
+
@stack = []
|
22
|
+
@layers = {}
|
23
23
|
end
|
24
24
|
|
25
|
-
sig {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
25
|
+
# T::Sig::WithoutRuntime.sig {
|
26
|
+
# override.params(
|
27
|
+
# block: T.nilable(T.proc.params(layer: Kuby::Docker::Layer).void)
|
28
|
+
# )
|
29
|
+
# .void
|
30
|
+
# }
|
31
31
|
def each(&block)
|
32
|
-
return to_enum(
|
33
|
-
@stack.each { |name| yield
|
32
|
+
return to_enum(__method__) unless block_given?
|
33
|
+
@stack.each { |name| yield layers[name] }
|
34
34
|
end
|
35
35
|
|
36
|
-
sig {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
36
|
+
# T::Sig::WithoutRuntime.sig {
|
37
|
+
# params(
|
38
|
+
# name: Symbol,
|
39
|
+
# layer: T.nilable(Layer),
|
40
|
+
# block: T.nilable(T.proc.params(df: Kuby::Docker::Dockerfile).void)
|
41
|
+
# )
|
42
|
+
# .void
|
43
|
+
# }
|
44
44
|
def use(name, layer = nil, &block)
|
45
45
|
stack << name
|
46
46
|
|
@@ -53,15 +53,15 @@ module Kuby
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
sig {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
56
|
+
# T::Sig::WithoutRuntime.sig {
|
57
|
+
# params(
|
58
|
+
# name: Symbol,
|
59
|
+
# layer: T.nilable(T.any(Layer, T::Hash[Symbol, T.untyped])),
|
60
|
+
# options: T::Hash[Symbol, T.untyped],
|
61
|
+
# block: T.nilable(T.proc.params(df: Kuby::Docker::Dockerfile).void)
|
62
|
+
# )
|
63
|
+
# .void
|
64
|
+
# }
|
65
65
|
def insert(name, layer = nil, options = {}, &block)
|
66
66
|
# this is truly gross but it's the only way I can think of to be able
|
67
67
|
# to call insert these two ways:
|
@@ -94,13 +94,13 @@ module Kuby
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
sig { params(name: Symbol).void }
|
97
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol).void }
|
98
98
|
def delete(name)
|
99
99
|
stack.delete(name)
|
100
100
|
layers.delete(name)
|
101
101
|
end
|
102
102
|
|
103
|
-
sig { params(name: Symbol).returns(T::Boolean) }
|
103
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol).returns(T::Boolean) }
|
104
104
|
def includes?(name)
|
105
105
|
layers.include?(name)
|
106
106
|
end
|
@@ -3,34 +3,34 @@
|
|
3
3
|
module Kuby
|
4
4
|
module Docker
|
5
5
|
class LocalTags
|
6
|
-
extend T::Sig
|
6
|
+
# extend T::Sig
|
7
7
|
|
8
|
-
sig { returns CLI }
|
8
|
+
# T::Sig::WithoutRuntime.sig { returns Kuby::Docker::CLI }
|
9
9
|
attr_reader :cli
|
10
10
|
|
11
|
-
sig { returns(String) }
|
11
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
12
12
|
attr_reader :image_url
|
13
13
|
|
14
|
-
sig {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
14
|
+
# T::Sig::WithoutRuntime.sig {
|
15
|
+
# params(
|
16
|
+
# cli: Kuby::Docker::CLI,
|
17
|
+
# image_url: String
|
18
|
+
# )
|
19
|
+
# .void
|
20
|
+
# }
|
21
21
|
def initialize(cli, image_url)
|
22
22
|
@cli = cli
|
23
23
|
@image_url = image_url
|
24
|
-
@latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag))
|
24
|
+
# @latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag))
|
25
25
|
end
|
26
26
|
|
27
|
-
sig { returns(T::Array[String]) }
|
27
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[String]) }
|
28
28
|
def tags
|
29
29
|
images = cli.images(image_url)
|
30
|
-
images.map { |image|
|
30
|
+
images.map { |image| image[:tag] }
|
31
31
|
end
|
32
32
|
|
33
|
-
sig { returns(T::Array[String]) }
|
33
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[String]) }
|
34
34
|
def latest_tags
|
35
35
|
# find "latest" tag
|
36
36
|
images = cli.images(image_url)
|
@@ -48,12 +48,12 @@ module Kuby
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
sig { returns(T::Array[TimestampTag]) }
|
51
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[Kuby::Docker::TimestampTag]) }
|
52
52
|
def timestamp_tags
|
53
53
|
tags.map { |t| TimestampTag.try_parse(t) }.compact
|
54
54
|
end
|
55
55
|
|
56
|
-
sig { returns(T.nilable(TimestampTag)) }
|
56
|
+
# T::Sig::WithoutRuntime.sig { returns(T.nilable(Kuby::Docker::TimestampTag)) }
|
57
57
|
def latest_timestamp_tag
|
58
58
|
@latest_timestamp_tag ||= timestamp_tags.sort.last
|
59
59
|
end
|
@@ -3,48 +3,48 @@
|
|
3
3
|
module Kuby
|
4
4
|
module Docker
|
5
5
|
class PackageList
|
6
|
-
extend T::Sig
|
7
|
-
extend T::Generic
|
6
|
+
# extend T::Sig
|
7
|
+
# extend T::Generic
|
8
8
|
|
9
|
-
Elem = type_member
|
9
|
+
# Elem = type_member { { fixed: Distro::PackageImpl } }
|
10
10
|
|
11
11
|
include Enumerable
|
12
12
|
|
13
|
-
sig { returns(T::Array[Distro::PackageImpl]) }
|
13
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[Distro::PackageImpl]) }
|
14
14
|
attr_reader :packages
|
15
15
|
|
16
|
-
sig { params(package_tuples: T::Array[[Symbol, T.nilable(String)]]).void }
|
16
|
+
# T::Sig::WithoutRuntime.sig { params(package_tuples: T::Array[[Symbol, T.nilable(String)]]).void }
|
17
17
|
def initialize(package_tuples)
|
18
|
-
@packages =
|
18
|
+
@packages = []
|
19
19
|
package_tuples.each { |name, version| add(name, version) }
|
20
20
|
end
|
21
21
|
|
22
|
-
sig { params(name: Symbol).returns(T.nilable(Distro::PackageImpl)) }
|
22
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol).returns(T.nilable(Distro::PackageImpl)) }
|
23
23
|
def [](name)
|
24
24
|
packages.find { |pkg| pkg.name == name }
|
25
25
|
end
|
26
26
|
|
27
|
-
sig { params(name: Symbol, version: T.nilable(String)).void }
|
27
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }
|
28
28
|
def add(name, version = nil)
|
29
29
|
packages << Packages::Package.new(name, version)
|
30
30
|
end
|
31
31
|
|
32
|
-
sig { params(name: String).void }
|
32
|
+
# T::Sig::WithoutRuntime.sig { params(name: String).void }
|
33
33
|
def delete(name)
|
34
34
|
packages.delete_if { |pkg| pkg.name == name }
|
35
35
|
end
|
36
36
|
|
37
|
-
sig {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
37
|
+
# T::Sig::WithoutRuntime.sig {
|
38
|
+
# override.params(
|
39
|
+
# block: T.proc.params(package: Distro::PackageImpl).void
|
40
|
+
# )
|
41
|
+
# .void
|
42
|
+
# }
|
43
43
|
def each(&block)
|
44
44
|
packages.each(&block)
|
45
45
|
end
|
46
46
|
|
47
|
-
sig { returns(T::Boolean) }
|
47
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
|
48
48
|
def empty?
|
49
49
|
packages.empty?
|
50
50
|
end
|
@@ -3,31 +3,31 @@
|
|
3
3
|
module Kuby
|
4
4
|
module Docker
|
5
5
|
class PackagePhase < Layer
|
6
|
-
extend T::Sig
|
6
|
+
# extend T::Sig
|
7
7
|
|
8
|
-
Operation = T.type_alias { [Symbol, Symbol, T.nilable(String)] }
|
8
|
+
# Operation = T.type_alias { [Symbol, Symbol, T.nilable(String)] }
|
9
9
|
|
10
|
-
sig { returns(T::Array[Operation]) }
|
10
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[Operation]) }
|
11
11
|
attr_reader :operations
|
12
12
|
|
13
|
-
sig { params(environment: Environment).void }
|
13
|
+
# T::Sig::WithoutRuntime.sig { params(environment: Kuby::Environment).void }
|
14
14
|
def initialize(environment)
|
15
15
|
super
|
16
16
|
|
17
|
-
@operations =
|
17
|
+
@operations = []
|
18
18
|
end
|
19
19
|
|
20
|
-
sig { params(package_name: Symbol, version: T.nilable(String)).void }
|
20
|
+
# T::Sig::WithoutRuntime.sig { params(package_name: Symbol, version: T.nilable(String)).void }
|
21
21
|
def add(package_name, version = nil)
|
22
22
|
operations << [:add, package_name, version]
|
23
23
|
end
|
24
24
|
|
25
|
-
sig { params(package_name: Symbol).void }
|
25
|
+
# T::Sig::WithoutRuntime.sig { params(package_name: Symbol).void }
|
26
26
|
def remove(package_name)
|
27
27
|
operations << [:remove, package_name, nil]
|
28
28
|
end
|
29
29
|
|
30
|
-
sig { override.params(dockerfile: Dockerfile).void }
|
30
|
+
# T::Sig::WithoutRuntime.sig { override.params(dockerfile: Kuby::Docker::Dockerfile).void }
|
31
31
|
def apply_to(dockerfile)
|
32
32
|
packages = distro_spec.default_packages.dup
|
33
33
|
|
@@ -50,18 +50,18 @@ module Kuby
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
sig { returns(Distro) }
|
53
|
+
# T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Distro) }
|
54
54
|
def distro_spec
|
55
55
|
environment.docker.distro_spec
|
56
56
|
end
|
57
57
|
|
58
|
-
sig {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
58
|
+
# T::Sig::WithoutRuntime.sig {
|
59
|
+
# params(
|
60
|
+
# package_name: Symbol,
|
61
|
+
# version: T.nilable(String)
|
62
|
+
# )
|
63
|
+
# .returns(Kuby::Docker::Distro::PackageImpl)
|
64
|
+
# }
|
65
65
|
def get_package(package_name, version)
|
66
66
|
if package = Kuby.packages[package_name]
|
67
67
|
package.with_version(version)
|
@@ -4,27 +4,27 @@ module Kuby
|
|
4
4
|
module Docker
|
5
5
|
module Packages
|
6
6
|
class ManagedPackage
|
7
|
-
extend T::Sig
|
7
|
+
# extend T::Sig
|
8
8
|
|
9
|
-
sig { returns(Symbol) }
|
9
|
+
# T::Sig::WithoutRuntime.sig { returns(Symbol) }
|
10
10
|
attr_reader :name
|
11
11
|
|
12
|
-
sig { returns(T::Hash[Symbol, String]) }
|
12
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, String]) }
|
13
13
|
attr_reader :names_per_distro
|
14
14
|
|
15
|
-
sig {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
15
|
+
# T::Sig::WithoutRuntime.sig {
|
16
|
+
# params(
|
17
|
+
# name: Symbol,
|
18
|
+
# names_per_distro: T::Hash[Symbol, String]
|
19
|
+
# )
|
20
|
+
# .void
|
21
|
+
# }
|
22
22
|
def initialize(name, names_per_distro)
|
23
23
|
@name = name
|
24
24
|
@names_per_distro = names_per_distro
|
25
25
|
end
|
26
26
|
|
27
|
-
sig { params(distro: Symbol).returns(String) }
|
27
|
+
# T::Sig::WithoutRuntime.sig { params(distro: Symbol).returns(String) }
|
28
28
|
def package_name_for(distro)
|
29
29
|
names_per_distro.fetch(distro) do
|
30
30
|
raise UnsupportedDistroError, "Couldn't install #{name} "\
|
@@ -32,12 +32,12 @@ module Kuby
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
sig { params(ver: String).returns(T.self_type) }
|
35
|
+
# T::Sig::WithoutRuntime.sig { params(ver: String).returns(T.self_type) }
|
36
36
|
def with_version(ver)
|
37
37
|
self
|
38
38
|
end
|
39
39
|
|
40
|
-
sig { returns(T::Boolean) }
|
40
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
|
41
41
|
def managed?
|
42
42
|
true
|
43
43
|
end
|
@@ -4,26 +4,26 @@ module Kuby
|
|
4
4
|
module Docker
|
5
5
|
module Packages
|
6
6
|
class Nodejs < Package
|
7
|
-
extend T::Sig
|
7
|
+
# extend T::Sig
|
8
8
|
|
9
|
-
sig { params(dockerfile: Dockerfile).void }
|
9
|
+
# T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }
|
10
10
|
def install_on_debian(dockerfile)
|
11
11
|
install_from_image("node:#{version}", dockerfile)
|
12
12
|
end
|
13
13
|
|
14
|
-
sig { params(dockerfile: Dockerfile).void }
|
14
|
+
# T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }
|
15
15
|
def install_on_alpine(dockerfile)
|
16
16
|
install_from_image("node:#{version}-alpine", dockerfile)
|
17
17
|
end
|
18
18
|
|
19
|
-
sig { returns(String) }
|
19
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
20
20
|
def version
|
21
21
|
@version || 'current'
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
sig { params(image: String, dockerfile: Dockerfile).void }
|
26
|
+
# T::Sig::WithoutRuntime.sig { params(image: String, dockerfile: Dockerfile).void }
|
27
27
|
def install_from_image(image, dockerfile)
|
28
28
|
dockerfile.insert_at(0) do
|
29
29
|
dockerfile.from(image, as: 'nodejs')
|
@@ -4,29 +4,29 @@ module Kuby
|
|
4
4
|
module Docker
|
5
5
|
module Packages
|
6
6
|
class Package
|
7
|
-
extend T::Sig
|
8
|
-
extend T::Helpers
|
7
|
+
# extend T::Sig
|
8
|
+
# extend T::Helpers
|
9
9
|
|
10
|
-
abstract!
|
10
|
+
# abstract!
|
11
11
|
|
12
|
-
sig { returns(Symbol) }
|
12
|
+
# T::Sig::WithoutRuntime.sig { returns(Symbol) }
|
13
13
|
attr_reader :name
|
14
14
|
|
15
|
-
sig { returns(T.nilable(String)) }
|
15
|
+
# T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
|
16
16
|
attr_reader :version
|
17
17
|
|
18
|
-
sig { params(name: Symbol, version: T.nilable(String)).void }
|
18
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }
|
19
19
|
def initialize(name, version = nil)
|
20
20
|
@name = name
|
21
21
|
@version = version
|
22
22
|
end
|
23
23
|
|
24
|
-
sig { params(ver: String).returns(T.self_type) }
|
24
|
+
# T::Sig::WithoutRuntime.sig { params(ver: String).returns(T.self_type) }
|
25
25
|
def with_version(ver)
|
26
26
|
self.class.new(name, ver)
|
27
27
|
end
|
28
28
|
|
29
|
-
sig { returns(T::Boolean) }
|
29
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
|
30
30
|
def managed?
|
31
31
|
false
|
32
32
|
end
|
@@ -4,27 +4,27 @@ module Kuby
|
|
4
4
|
module Docker
|
5
5
|
module Packages
|
6
6
|
class SimpleManagedPackage
|
7
|
-
extend T::Sig
|
7
|
+
# extend T::Sig
|
8
8
|
|
9
|
-
sig { returns(String) }
|
9
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
10
10
|
attr_reader :name
|
11
11
|
|
12
|
-
sig { params(name: String).void }
|
12
|
+
# T::Sig::WithoutRuntime.sig { params(name: T.any(String, Symbol)).void }
|
13
13
|
def initialize(name)
|
14
|
-
@name = name
|
14
|
+
@name = name.to_s
|
15
15
|
end
|
16
16
|
|
17
|
-
sig { params(distro: Symbol).returns(String) }
|
17
|
+
# T::Sig::WithoutRuntime.sig { params(distro: Symbol).returns(String) }
|
18
18
|
def package_name_for(distro)
|
19
19
|
name
|
20
20
|
end
|
21
21
|
|
22
|
-
sig { params(ver: String).returns(T.self_type) }
|
22
|
+
# T::Sig::WithoutRuntime.sig { params(ver: String).returns(T.self_type) }
|
23
23
|
def with_version(ver)
|
24
24
|
self
|
25
25
|
end
|
26
26
|
|
27
|
-
sig { returns(T::Boolean) }
|
27
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Boolean) }
|
28
28
|
def managed?
|
29
29
|
true
|
30
30
|
end
|
@@ -4,16 +4,16 @@ module Kuby
|
|
4
4
|
module Docker
|
5
5
|
module Packages
|
6
6
|
class Yarn < Package
|
7
|
-
extend T::Sig
|
7
|
+
# extend T::Sig
|
8
8
|
|
9
|
-
sig { params(name: Symbol, version: T.nilable(String)).void }
|
9
|
+
# T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }
|
10
10
|
def initialize(name, version = nil)
|
11
11
|
super
|
12
12
|
|
13
|
-
@url = T.let(@url, T.nilable(String))
|
13
|
+
# @url = T.let(@url, T.nilable(String))
|
14
14
|
end
|
15
15
|
|
16
|
-
sig { params(dockerfile: Dockerfile).void }
|
16
|
+
# T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }
|
17
17
|
def install_on_debian(dockerfile)
|
18
18
|
dockerfile.run(<<~CMD.strip)
|
19
19
|
wget #{url} && \\
|
@@ -29,7 +29,7 @@ module Kuby
|
|
29
29
|
dockerfile.env("PATH=$PATH:/opt/yarn/bin")
|
30
30
|
end
|
31
31
|
|
32
|
-
sig { params(dockerfile: Dockerfile).void }
|
32
|
+
# T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }
|
33
33
|
def install_on_alpine(dockerfile)
|
34
34
|
dockerfile.run(<<~CMD.strip)
|
35
35
|
wget #{url} && \\
|
@@ -47,7 +47,7 @@ module Kuby
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
sig { returns(String) }
|
50
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
51
51
|
def url
|
52
52
|
@url ||= if version
|
53
53
|
"https://github.com/yarnpkg/yarn/releases/download/v#{version}/yarn-v#{version}.tar.gz"
|
@@ -5,41 +5,41 @@ require 'docker/remote'
|
|
5
5
|
module Kuby
|
6
6
|
module Docker
|
7
7
|
class RemoteTags
|
8
|
-
extend T::Sig
|
8
|
+
# extend T::Sig
|
9
9
|
|
10
|
-
sig { returns(::Docker::Remote::Client) }
|
10
|
+
# T::Sig::WithoutRuntime.sig { returns(::Docker::Remote::Client) }
|
11
11
|
attr_reader :remote_client
|
12
12
|
|
13
|
-
sig { returns(String) }
|
13
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
14
14
|
attr_reader :image_url
|
15
15
|
|
16
|
-
sig {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
16
|
+
# T::Sig::WithoutRuntime.sig {
|
17
|
+
# params(
|
18
|
+
# remote_client: ::Docker::Remote::Client,
|
19
|
+
# image_url: String
|
20
|
+
# )
|
21
|
+
# .void
|
22
|
+
# }
|
23
23
|
def initialize(remote_client, image_url)
|
24
24
|
@remote_client = remote_client
|
25
25
|
@image_url = image_url
|
26
26
|
end
|
27
27
|
|
28
|
-
sig { returns(T::Array[String]) }
|
28
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[String]) }
|
29
29
|
def tags
|
30
|
-
remote_client.tags
|
31
|
-
rescue ::Docker::Remote::UnknownRepoError
|
32
|
-
#
|
30
|
+
remote_client.tags || []
|
31
|
+
rescue ::Docker::Remote::UnknownRepoError, ::Docker::Remote::UnauthorizedError, ::Docker::Remote::TooManyRetriesError
|
32
|
+
# these can happen if we've never pushed to the repo before
|
33
33
|
[]
|
34
34
|
end
|
35
35
|
|
36
|
-
sig { returns(T::Array[String]) }
|
36
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[String]) }
|
37
37
|
def latest_tags
|
38
38
|
# not available for remote repos
|
39
39
|
[]
|
40
40
|
end
|
41
41
|
|
42
|
-
sig { returns(T::Array[TimestampTag]) }
|
42
|
+
# T::Sig::WithoutRuntime.sig { returns(T::Array[Kuby::Docker::TimestampTag]) }
|
43
43
|
def timestamp_tags
|
44
44
|
tags.map { |t| TimestampTag.try_parse(t) }.compact
|
45
45
|
end
|
@@ -3,39 +3,39 @@
|
|
3
3
|
module Kuby
|
4
4
|
module Docker
|
5
5
|
class SetupPhase < Layer
|
6
|
-
extend T::Sig
|
6
|
+
# extend T::Sig
|
7
7
|
|
8
|
-
DEFAULT_WORKING_DIR =
|
8
|
+
DEFAULT_WORKING_DIR = '/usr/src/app'.freeze
|
9
9
|
|
10
|
-
sig { params(base_image: String).
|
10
|
+
# T::Sig::WithoutRuntime.sig { params(base_image: String).returns(String) }
|
11
11
|
attr_writer :base_image
|
12
12
|
|
13
|
-
sig { returns(T.nilable(String)) }
|
13
|
+
# T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
|
14
14
|
attr_reader :working_dir
|
15
15
|
|
16
|
-
sig { params(working_dir: String).
|
16
|
+
# T::Sig::WithoutRuntime.sig { params(working_dir: String).returns(String) }
|
17
17
|
attr_writer :working_dir
|
18
18
|
|
19
|
-
sig { returns(T.nilable(String)) }
|
19
|
+
# T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
|
20
20
|
attr_reader :rails_env
|
21
21
|
|
22
|
-
sig { params(rails_env: String).
|
22
|
+
# T::Sig::WithoutRuntime.sig { params(rails_env: String).returns(String) }
|
23
23
|
attr_writer :rails_env
|
24
24
|
|
25
|
-
sig { returns(
|
25
|
+
# T::Sig::WithoutRuntime.sig { returns(Docker::Spec) }
|
26
26
|
attr_reader :docker_spec
|
27
27
|
|
28
|
-
sig { params(environment: Environment, docker_spec: Docker::Spec).void }
|
28
|
+
# T::Sig::WithoutRuntime.sig { params(environment: Environment, docker_spec: Docker::Spec).void }
|
29
29
|
def initialize(environment, docker_spec)
|
30
30
|
super(environment)
|
31
31
|
|
32
|
-
@base_image = T.let(@base_image, T.nilable(String))
|
33
|
-
@working_dir = T.let(@working_dir, T.nilable(String))
|
34
|
-
@rails_env = T.let(@rails_env, T.nilable(String))
|
35
|
-
@docker_spec =
|
32
|
+
# @base_image = T.let(@base_image, T.nilable(String))
|
33
|
+
# @working_dir = T.let(@working_dir, T.nilable(String))
|
34
|
+
# @rails_env = T.let(@rails_env, T.nilable(String))
|
35
|
+
@docker_spec = docker_spec
|
36
36
|
end
|
37
37
|
|
38
|
-
sig { override.params(dockerfile: Dockerfile).void }
|
38
|
+
# T::Sig::WithoutRuntime.sig { override.params(dockerfile: Dockerfile).void }
|
39
39
|
def apply_to(dockerfile)
|
40
40
|
dockerfile.from(base_image)
|
41
41
|
dockerfile.workdir(working_dir || DEFAULT_WORKING_DIR)
|
@@ -44,24 +44,22 @@ module Kuby
|
|
44
44
|
dockerfile.arg('RAILS_MASTER_KEY')
|
45
45
|
end
|
46
46
|
|
47
|
-
sig { returns(String) }
|
47
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
48
48
|
def base_image
|
49
49
|
@base_image || default_base_image
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
sig { returns(String) }
|
54
|
+
# T::Sig::WithoutRuntime.sig { returns(String) }
|
55
55
|
def default_base_image
|
56
|
-
|
57
|
-
|
58
|
-
case spec.distro_name
|
56
|
+
case docker_spec.distro_name
|
59
57
|
when :debian
|
60
58
|
"ruby:#{RUBY_VERSION}"
|
61
59
|
when :alpine
|
62
60
|
"ruby:#{RUBY_VERSION}-alpine"
|
63
61
|
else
|
64
|
-
raise MissingDistroError, "distro '#{
|
62
|
+
raise MissingDistroError, "distro '#{docker_spec.distro_name}' hasn't been registered"
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|