kamal 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kamal/cli/accessory.rb +12 -8
- data/lib/kamal/cli/healthcheck.rb +1 -0
- data/lib/kamal/cli/main.rb +4 -2
- data/lib/kamal/cli/templates/deploy.yml +2 -3
- data/lib/kamal/cli/templates/sample_hooks/pre-build.sample +1 -1
- data/lib/kamal/commander.rb +21 -4
- data/lib/kamal/commands/healthcheck.rb +5 -5
- data/lib/kamal/commands/lock.rb +1 -0
- data/lib/kamal/configuration/accessory.rb +10 -6
- data/lib/kamal/configuration/role.rb +10 -2
- data/lib/kamal/configuration.rb +9 -13
- data/lib/kamal/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2071f73b4e7a6d63939bbfd4f07caacd95aa637964c07fffaa261711f602b5f6
|
4
|
+
data.tar.gz: 0c265ae0c39673018ece39e7fc16acfcc6e7148efdf6a011827548ffb5a332de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d21ac54e6eea13f7e89280d3358a342e54e629f402864b591538d018f19f3275fe88104c06e85a73e3846ddfd606f3106dfb3ab7757629dd931e6b63f111767
|
7
|
+
data.tar.gz: be9bc4f8a641ef661adb78af0853ee3045d93f40d48c357627f80a5c43a5295125b4629658332b314c45f6134b5b87f03e386b0c432b734a5ca838fda0a027e2
|
data/lib/kamal/cli/accessory.rb
CHANGED
@@ -49,17 +49,21 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
desc "reboot [NAME]", "Reboot existing accessory on host (stop container, remove container, start new container)"
|
52
|
+
desc "reboot [NAME]", "Reboot existing accessory on host (stop container, remove container, start new container; use NAME=all to boot all accessories)"
|
53
53
|
def reboot(name)
|
54
54
|
mutating do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
if name == "all"
|
56
|
+
KAMAL.accessory_names.each { |accessory_name| reboot(accessory_name) }
|
57
|
+
else
|
58
|
+
with_accessory(name) do |accessory|
|
59
|
+
on(accessory.hosts) do
|
60
|
+
execute *KAMAL.registry.login
|
61
|
+
end
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
stop(name)
|
64
|
+
remove_container(name)
|
65
|
+
boot(name, login: false)
|
66
|
+
end
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
@@ -3,6 +3,7 @@ class Kamal::Cli::Healthcheck < Kamal::Cli::Base
|
|
3
3
|
|
4
4
|
desc "perform", "Health check current app version"
|
5
5
|
def perform
|
6
|
+
raise "The primary host is not configured to run Traefik" unless KAMAL.config.role(KAMAL.config.primary_role).running_traefik?
|
6
7
|
on(KAMAL.primary_host) do
|
7
8
|
begin
|
8
9
|
execute *KAMAL.healthcheck.run
|
data/lib/kamal/cli/main.rb
CHANGED
@@ -38,8 +38,10 @@ class Kamal::Cli::Main < Kamal::Cli::Base
|
|
38
38
|
say "Ensure Traefik is running...", :magenta
|
39
39
|
invoke "kamal:cli:traefik:boot", [], invoke_options
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
if KAMAL.config.role(KAMAL.config.primary_role).running_traefik?
|
42
|
+
say "Ensure app can pass healthcheck...", :magenta
|
43
|
+
invoke "kamal:cli:healthcheck:perform", [], invoke_options
|
44
|
+
end
|
43
45
|
|
44
46
|
say "Detect stale containers...", :magenta
|
45
47
|
invoke "kamal:cli:app:stale_containers", [], invoke_options.merge(stop: true)
|
@@ -84,13 +84,12 @@ registry:
|
|
84
84
|
# limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
|
85
85
|
# wait: 2
|
86
86
|
|
87
|
-
# Configure the role used to determine the
|
87
|
+
# Configure the role used to determine the primary_host. This host takes
|
88
88
|
# deploy locks, runs health checks during the deploy, and follow logs, etc.
|
89
|
-
# This role should have traefik enabled.
|
90
89
|
#
|
91
90
|
# Caution: there's no support for role renaming yet, so be careful to cleanup
|
92
91
|
# the previous role on the deployed hosts.
|
93
|
-
#
|
92
|
+
# primary_role: web
|
94
93
|
|
95
94
|
# Controls if we abort when see a role with no hosts. Disabling this may be
|
96
95
|
# useful for more complex deploy configurations.
|
data/lib/kamal/commander.rb
CHANGED
@@ -24,19 +24,36 @@ class Kamal::Commander
|
|
24
24
|
attr_reader :specific_roles, :specific_hosts
|
25
25
|
|
26
26
|
def specific_primary!
|
27
|
-
self.specific_hosts = [ config.
|
27
|
+
self.specific_hosts = [ config.primary_host ]
|
28
28
|
end
|
29
29
|
|
30
30
|
def specific_roles=(role_names)
|
31
|
-
|
31
|
+
if role_names.present?
|
32
|
+
@specific_roles = Kamal::Utils.filter_specific_items(role_names, config.roles)
|
33
|
+
|
34
|
+
if @specific_roles.empty?
|
35
|
+
raise ArgumentError, "No --roles match for #{role_names.join(',')}"
|
36
|
+
end
|
37
|
+
|
38
|
+
@specific_roles
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
def specific_hosts=(hosts)
|
35
|
-
|
43
|
+
if hosts.present?
|
44
|
+
@specific_hosts = Kamal::Utils.filter_specific_items(hosts, config.all_hosts)
|
45
|
+
|
46
|
+
if @specific_hosts.empty?
|
47
|
+
raise ArgumentError, "No --hosts match for #{hosts.join(',')}"
|
48
|
+
end
|
49
|
+
|
50
|
+
@specific_hosts
|
51
|
+
end
|
36
52
|
end
|
37
53
|
|
38
54
|
def primary_host
|
39
|
-
|
55
|
+
# Given a list of specific roles, make an effort to match up with the primary_role
|
56
|
+
specific_hosts&.first || specific_roles&.detect { |role| role.name == config.primary_role }&.primary_host || specific_roles&.first&.primary_host || config.primary_host
|
40
57
|
end
|
41
58
|
|
42
59
|
def primary_role
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Kamal::Commands::Healthcheck < Kamal::Commands::Base
|
2
2
|
|
3
3
|
def run
|
4
|
-
|
4
|
+
primary = config.role(config.primary_role)
|
5
5
|
|
6
6
|
docker :run,
|
7
7
|
"--detach",
|
@@ -9,12 +9,12 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base
|
|
9
9
|
"--publish", "#{exposed_port}:#{config.healthcheck["port"]}",
|
10
10
|
"--label", "service=#{config.healthcheck_service}",
|
11
11
|
"-e", "KAMAL_CONTAINER_NAME=\"#{config.healthcheck_service}\"",
|
12
|
-
*
|
13
|
-
*
|
12
|
+
*primary.env_args,
|
13
|
+
*primary.health_check_args(cord: false),
|
14
14
|
*config.volume_args,
|
15
|
-
*
|
15
|
+
*primary.option_args,
|
16
16
|
config.absolute_image,
|
17
|
-
|
17
|
+
primary.cmd
|
18
18
|
end
|
19
19
|
|
20
20
|
def status
|
data/lib/kamal/commands/lock.rb
CHANGED
@@ -70,8 +70,8 @@ class Kamal::Configuration::Accessory
|
|
70
70
|
|
71
71
|
def directories
|
72
72
|
specifics["directories"]&.to_h do |host_to_container_mapping|
|
73
|
-
|
74
|
-
[ expand_host_path(
|
73
|
+
host_path, container_path = host_to_container_mapping.split(":")
|
74
|
+
[ expand_host_path(host_path), container_path ]
|
75
75
|
end || {}
|
76
76
|
end
|
77
77
|
|
@@ -138,13 +138,17 @@ class Kamal::Configuration::Accessory
|
|
138
138
|
|
139
139
|
def remote_directories_as_volumes
|
140
140
|
specifics["directories"]&.collect do |host_to_container_mapping|
|
141
|
-
|
142
|
-
[ expand_host_path(
|
141
|
+
host_path, container_path = host_to_container_mapping.split(":")
|
142
|
+
[ expand_host_path(host_path), container_path ].join(":")
|
143
143
|
end || []
|
144
144
|
end
|
145
145
|
|
146
|
-
def expand_host_path(
|
147
|
-
"#{service_data_directory}/#{
|
146
|
+
def expand_host_path(host_path)
|
147
|
+
absolute_path?(host_path) ? host_path : "#{service_data_directory}/#{host_path}"
|
148
|
+
end
|
149
|
+
|
150
|
+
def absolute_path?(path)
|
151
|
+
Pathname.new(path).absolute?
|
148
152
|
end
|
149
153
|
|
150
154
|
def service_data_directory
|
@@ -93,7 +93,15 @@ class Kamal::Configuration::Role
|
|
93
93
|
|
94
94
|
|
95
95
|
def running_traefik?
|
96
|
-
|
96
|
+
if specializations["traefik"].nil?
|
97
|
+
primary?
|
98
|
+
else
|
99
|
+
specializations["traefik"]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def primary?
|
104
|
+
@config.primary_role == name
|
97
105
|
end
|
98
106
|
|
99
107
|
|
@@ -231,7 +239,7 @@ class Kamal::Configuration::Role
|
|
231
239
|
clear_app_env = config.env["secret"] ? Array(config.env["clear"]) : Array(config.env["clear"] || config.env)
|
232
240
|
clear_role_env = specialized_env["secret"] ? Array(specialized_env["clear"]) : Array(specialized_env["clear"] || specialized_env)
|
233
241
|
|
234
|
-
new_env["clear"] = (
|
242
|
+
new_env["clear"] = clear_app_env.to_h.merge(clear_role_env.to_h)
|
235
243
|
end
|
236
244
|
end
|
237
245
|
|
data/lib/kamal/configuration.rb
CHANGED
@@ -91,8 +91,8 @@ class Kamal::Configuration
|
|
91
91
|
roles.flat_map(&:hosts).uniq
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
95
|
-
role(
|
94
|
+
def primary_host
|
95
|
+
role(primary_role)&.primary_host
|
96
96
|
end
|
97
97
|
|
98
98
|
def traefik_roles
|
@@ -208,8 +208,8 @@ class Kamal::Configuration
|
|
208
208
|
raw_config.asset_path
|
209
209
|
end
|
210
210
|
|
211
|
-
def
|
212
|
-
raw_config.
|
211
|
+
def primary_role
|
212
|
+
raw_config.primary_role || "web"
|
213
213
|
end
|
214
214
|
|
215
215
|
def allow_empty_roles?
|
@@ -225,7 +225,7 @@ class Kamal::Configuration
|
|
225
225
|
{
|
226
226
|
roles: role_names,
|
227
227
|
hosts: all_hosts,
|
228
|
-
primary_host:
|
228
|
+
primary_host: primary_host,
|
229
229
|
version: version,
|
230
230
|
repository: repository,
|
231
231
|
absolute_image: absolute_image,
|
@@ -264,16 +264,12 @@ class Kamal::Configuration
|
|
264
264
|
raise ArgumentError, "You must specify a password for the registry in config/deploy.yml (or set the ENV variable if that's used)"
|
265
265
|
end
|
266
266
|
|
267
|
-
unless role_names.include?(
|
268
|
-
raise ArgumentError, "The
|
267
|
+
unless role_names.include?(primary_role)
|
268
|
+
raise ArgumentError, "The primary_role #{primary_role} isn't defined"
|
269
269
|
end
|
270
270
|
|
271
|
-
|
272
|
-
raise ArgumentError, "
|
273
|
-
end
|
274
|
-
|
275
|
-
if role(primary_web_role).hosts.empty?
|
276
|
-
raise ArgumentError, "No servers specified for the #{primary_web_role} primary_web_role"
|
271
|
+
if role(primary_role).hosts.empty?
|
272
|
+
raise ArgumentError, "No servers specified for the #{primary_role} primary_role"
|
277
273
|
end
|
278
274
|
|
279
275
|
unless allow_empty_roles?
|
data/lib/kamal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.2'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: base64
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.2'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.2'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: debug
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
286
|
- !ruby/object:Gem::Version
|
273
287
|
version: '0'
|
274
288
|
requirements: []
|
275
|
-
rubygems_version: 3.
|
289
|
+
rubygems_version: 3.5.1
|
276
290
|
signing_key:
|
277
291
|
specification_version: 4
|
278
292
|
summary: Deploy web apps in containers to servers running Docker with zero downtime.
|