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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efc8817e4bba2417ad480b7297b323d11bd88ec87993fb4c8a1bb09ffbb3f4a4
4
- data.tar.gz: 6c1269582ae3ccf90e9b4532b2fecbdd0723493413f82036038a121707f76ce3
3
+ metadata.gz: 4a11bf8b2153b8bc4323e4b03e289d7c0c5e60a9dcc9012103ae701ae2c3256b
4
+ data.tar.gz: bc4b5c88e63a717fc539c71c00fb8207ee78693ade9658ac8effd3ecdd5249ab
5
5
  SHA512:
6
- metadata.gz: d9862df894f9e105bfe38a88ac93289e9fa89b51d69200cea6f5bd9f4483c74d31e2db39aa2d601aeb620d5f1beac5ca05efe94803e42f79cf3ba61e380b3f6d
7
- data.tar.gz: 5e03468f451046a73425599db6dba15565d960f244d622bd2248c00e2d3f89db4f96cffed4dd6719d3025211ff0cb725a50020d81b8f09e6a64a6b41a2836b63
6
+ metadata.gz: b8cbc84077617cfd72ad225cb458b0df9d36fe88b2f2a640bec9f012b4f92272d5cd62617580e75f217715be97e88c126bfe842dcdc1ab262c82db3fc9e0c746
7
+ data.tar.gz: c3e1de191ebcf4621fe15e59ee8b976491a58e8ffbd40a8862d15040837b7669f7e26372382711b118eb357035f047d920dd7817de7fc415aa5b8aa8a7e74a60
@@ -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
- with_accessory(name) do |accessory|
56
- on(accessory.hosts) do
57
- execute *KAMAL.registry.login
58
- end
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
- stop(name)
61
- remove_container(name)
62
- boot(name, login: false)
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
@@ -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
- say "Ensure app can pass healthcheck...", :magenta
42
- invoke "kamal:cli:healthcheck:perform", [], invoke_options
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 primary_web_host. This host takes
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
- # primary_web_role: web
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.
@@ -32,7 +32,7 @@ fi
32
32
  current_branch=$(git branch --show-current)
33
33
 
34
34
  if [ -z "$current_branch" ]; then
35
- echo "No git remote set, aborting..." >&2
35
+ echo "Not on a git branch, aborting..." >&2
36
36
  exit 1
37
37
  fi
38
38
 
@@ -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.primary_web_host ]
27
+ self.specific_hosts = [ config.primary_host ]
28
28
  end
29
29
 
30
30
  def specific_roles=(role_names)
31
- @specific_roles = Kamal::Utils.filter_specific_items(role_names, config.roles) if role_names.present?
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
- @specific_hosts = Kamal::Utils.filter_specific_items(hosts, config.all_hosts) if hosts.present?
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
- specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_web_host
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
- web = config.role(config.primary_web_role)
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
- *web.env_args,
13
- *web.health_check_args(cord: false),
12
+ *primary.env_args,
13
+ *primary.health_check_args(cord: false),
14
14
  *config.volume_args,
15
- *web.option_args,
15
+ *primary.option_args,
16
16
  config.absolute_image,
17
- web.cmd
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
- host_relative_path, container_path = host_to_container_mapping.split(":")
74
- [ expand_host_path(host_relative_path), container_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
- host_relative_path, container_path = host_to_container_mapping.split(":")
142
- [ expand_host_path(host_relative_path), container_path ].join(":")
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(host_relative_path)
147
- "#{service_data_directory}/#{host_relative_path}"
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
- name.web? || specializations["traefik"]
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
 
@@ -91,8 +91,8 @@ class Kamal::Configuration
91
91
  roles.flat_map(&:hosts).uniq
92
92
  end
93
93
 
94
- def primary_web_host
95
- role(primary_web_role)&.primary_host
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 primary_web_role
212
- raw_config.primary_web_role || "web"
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: primary_web_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?(primary_web_role)
268
- raise ArgumentError, "The primary_web_role #{primary_web_role} isn't defined"
267
+ unless role_names.include?(primary_role)
268
+ raise ArgumentError, "The primary_role #{primary_role} isn't defined"
269
269
  end
270
270
 
271
- unless traefik_role_names.include?(primary_web_role)
272
- raise ArgumentError, "Role #{primary_web_role} needs to have traefik enabled"
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
@@ -1,3 +1,3 @@
1
1
  module Kamal
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
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.2.0
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-15 00:00:00.000000000 Z
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.21
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.