kamal 1.2.0 → 1.3.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/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/configuration/accessory.rb +10 -6
- data/lib/kamal/configuration/role.rb +9 -1
- data/lib/kamal/configuration.rb +9 -13
- data/lib/kamal/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a11bf8b2153b8bc4323e4b03e289d7c0c5e60a9dcc9012103ae701ae2c3256b
|
4
|
+
data.tar.gz: bc4b5c88e63a717fc539c71c00fb8207ee78693ade9658ac8effd3ecdd5249ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8cbc84077617cfd72ad225cb458b0df9d36fe88b2f2a640bec9f012b4f92272d5cd62617580e75f217715be97e88c126bfe842dcdc1ab262c82db3fc9e0c746
|
7
|
+
data.tar.gz: c3e1de191ebcf4621fe15e59ee8b976491a58e8ffbd40a8862d15040837b7669f7e26372382711b118eb357035f047d920dd7817de7fc415aa5b8aa8a7e74a60
|
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
|
@@ -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
|
|
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.0
|
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: 2023-11-
|
11
|
+
date: 2023-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
- !ruby/object:Gem::Version
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
|
-
rubygems_version: 3.4.
|
275
|
+
rubygems_version: 3.4.22
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Deploy web apps in containers to servers running Docker with zero downtime.
|