Skip to content

Commit b225ae0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into local-docker-registry
2 parents 4286709 + 031f55e commit b225ae0

36 files changed

+417
-221
lines changed

Gemfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
PATH
22
remote: .
33
specs:
4-
kamal (2.5.3)
4+
kamal (2.6.0)
55
activesupport (>= 7.0)
66
base64 (~> 0.2)
77
bcrypt_pbkdf (~> 1.0)
88
concurrent-ruby (~> 1.2)
99
dotenv (~> 3.1)
10-
ed25519 (~> 1.2)
10+
ed25519 (~> 1.4)
1111
net-ssh (~> 7.3)
1212
sshkit (>= 1.23.0, < 2.0)
1313
thor (~> 1.3)
@@ -60,7 +60,7 @@ GEM
6060
reline (>= 0.3.8)
6161
dotenv (3.1.5)
6262
drb (2.2.1)
63-
ed25519 (1.3.0)
63+
ed25519 (1.4.0)
6464
erubi (1.13.0)
6565
i18n (1.14.6)
6666
concurrent-ruby (~> 1.0)
@@ -82,15 +82,15 @@ GEM
8282
net-sftp (4.0.0)
8383
net-ssh (>= 5.0.0, < 8.0.0)
8484
net-ssh (7.3.0)
85-
nokogiri (1.18.4-aarch64-linux-musl)
85+
nokogiri (1.18.8-aarch64-linux-musl)
8686
racc (~> 1.4)
87-
nokogiri (1.18.4-arm64-darwin)
87+
nokogiri (1.18.8-arm64-darwin)
8888
racc (~> 1.4)
89-
nokogiri (1.18.4-x86_64-darwin)
89+
nokogiri (1.18.8-x86_64-darwin)
9090
racc (~> 1.4)
91-
nokogiri (1.18.4-x86_64-linux-gnu)
91+
nokogiri (1.18.8-x86_64-linux-gnu)
9292
racc (~> 1.4)
93-
nokogiri (1.18.4-x86_64-linux-musl)
93+
nokogiri (1.18.8-x86_64-linux-musl)
9494
racc (~> 1.4)
9595
ostruct (0.6.1)
9696
parallel (1.26.3)

kamal.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
spec.add_dependency "thor", "~> 1.3"
1818
spec.add_dependency "dotenv", "~> 3.1"
1919
spec.add_dependency "zeitwerk", ">= 2.6.18", "< 3.0"
20-
spec.add_dependency "ed25519", "~> 1.2"
20+
spec.add_dependency "ed25519", "~> 1.4"
2121
spec.add_dependency "bcrypt_pbkdf", "~> 1.0"
2222
spec.add_dependency "concurrent-ruby", "~> 1.2"
2323
spec.add_dependency "base64", "~> 0.2"

lib/kamal/cli/app.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def exec(*cmd)
112112
raise ArgumentError, "Detach is not compatible with #{incompatible_options.join(" or ")}"
113113
end
114114

115+
if cmd.empty?
116+
raise ArgumentError, "No command provided. You must specify a command to execute."
117+
end
118+
115119
cmd = Kamal::Utils.join_commands(cmd)
116120
env = options[:env]
117121
detach = options[:detach]

lib/kamal/cli/app/error_pages.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def run
1313
if KAMAL.config.error_pages_path
1414
with_error_pages_tmpdir do |local_error_pages_dir|
1515
execute *KAMAL.app.create_error_pages_directory
16-
upload! local_error_pages_dir, KAMAL.config.proxy_error_pages_directory, mode: "0700", recursive: true
16+
upload! local_error_pages_dir, KAMAL.config.proxy_boot.error_pages_directory, mode: "0700", recursive: true
1717
end
1818
end
1919
end

lib/kamal/cli/base.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ def raise_if_locked
133133

134134
def run_hook(hook, **extra_details)
135135
if !options[:skip_hooks] && KAMAL.hook.hook_exists?(hook)
136-
details = { hosts: KAMAL.hosts.join(","), roles: KAMAL.specific_roles&.join(","), command: command, subcommand: subcommand }.compact
136+
details = {
137+
hosts: KAMAL.hosts.join(","),
138+
roles: KAMAL.specific_roles&.join(","),
139+
lock: KAMAL.holding_lock?.to_s,
140+
command: command,
141+
subcommand: subcommand
142+
}.compact
137143

138144
say "Running the #{hook} hook...", :magenta
139145
with_env KAMAL.hook.env(**details, **extra_details) do

lib/kamal/cli/proxy.rb

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ def boot
1313

1414
version = capture_with_info(*KAMAL.proxy.version).strip.presence
1515

16-
if version && Kamal::Utils.older_version?(version, Kamal::Configuration::PROXY_MINIMUM_VERSION)
17-
raise "kamal-proxy version #{version} is too old, run `kamal proxy reboot` in order to update to at least #{Kamal::Configuration::PROXY_MINIMUM_VERSION}"
16+
if version && Kamal::Utils.older_version?(version, Kamal::Configuration::Proxy::Boot::MINIMUM_VERSION)
17+
raise "kamal-proxy version #{version} is too old, run `kamal proxy reboot` in order to update to at least #{Kamal::Configuration::Proxy::Boot::MINIMUM_VERSION}"
1818
end
19+
execute *KAMAL.proxy.ensure_apps_config_directory
1920
execute *KAMAL.proxy.start_or_run
2021
end
2122
end
@@ -24,49 +25,63 @@ def boot
2425
desc "boot_config <set|get|reset>", "Manage kamal-proxy boot configuration"
2526
option :publish, type: :boolean, default: true, desc: "Publish the proxy ports on the host"
2627
option :publish_host_ip, type: :string, repeatable: true, default: nil, desc: "Host IP address to bind HTTP/HTTPS traffic to. Defaults to all interfaces"
27-
option :http_port, type: :numeric, default: Kamal::Configuration::PROXY_HTTP_PORT, desc: "HTTP port to publish on the host"
28-
option :https_port, type: :numeric, default: Kamal::Configuration::PROXY_HTTPS_PORT, desc: "HTTPS port to publish on the host"
29-
option :log_max_size, type: :string, default: Kamal::Configuration::PROXY_LOG_MAX_SIZE, desc: "Max size of proxy logs"
28+
option :http_port, type: :numeric, default: Kamal::Configuration::Proxy::Boot::DEFAULT_HTTP_PORT, desc: "HTTP port to publish on the host"
29+
option :https_port, type: :numeric, default: Kamal::Configuration::Proxy::Boot::DEFAULT_HTTPS_PORT, desc: "HTTPS port to publish on the host"
30+
option :log_max_size, type: :string, default: Kamal::Configuration::Proxy::Boot::DEFAULT_LOG_MAX_SIZE, desc: "Max size of proxy logs"
3031
option :registry, type: :string, default: nil, desc: "Registry to use for the proxy image"
3132
option :repository, type: :string, default: nil, desc: "Repository for the proxy image"
3233
option :image_version, type: :string, default: nil, desc: "Version of the proxy to run"
34+
option :metrics_port, type: :numeric, default: nil, desc: "Port to report prometheus metrics on"
35+
option :debug, type: :boolean, default: false, desc: "Whether to run the proxy in debug mode"
3336
option :docker_options, type: :array, default: [], desc: "Docker options to pass to the proxy container", banner: "option=value option2=value2"
3437
def boot_config(subcommand)
38+
proxy_boot_config = KAMAL.config.proxy_boot
39+
3540
case subcommand
3641
when "set"
3742
boot_options = [
38-
*(KAMAL.config.proxy_publish_args(options[:http_port], options[:https_port], options[:publish_host_ip]) if options[:publish]),
39-
*(KAMAL.config.proxy_logging_args(options[:log_max_size])),
43+
*(proxy_boot_config.publish_args(options[:http_port], options[:https_port], options[:publish_host_ip]) if options[:publish]),
44+
*(proxy_boot_config.logging_args(options[:log_max_size])),
45+
*("--expose=#{options[:metrics_port]}" if options[:metrics_port]),
4046
*options[:docker_options].map { |option| "--#{option}" }
4147
]
4248

4349
image = [
4450
options[:registry].presence,
45-
options[:repository].presence || KAMAL.config.proxy_repository_name,
46-
KAMAL.config.proxy_image_name
51+
options[:repository].presence || proxy_boot_config.repository_name,
52+
proxy_boot_config.image_name
4753
].compact.join("/")
4854

4955
image_version = options[:image_version]
5056

57+
run_command_options = { debug: options[:debug] || nil, "metrics-port": options[:metrics_port] }.compact
58+
run_command = "kamal-proxy run #{Kamal::Utils.optionize(run_command_options).join(" ")}" if run_command_options.any?
59+
5160
on(KAMAL.proxy_hosts) do |host|
5261
execute(*KAMAL.proxy.ensure_proxy_directory)
53-
if boot_options != KAMAL.config.proxy_default_boot_options
54-
upload! StringIO.new(boot_options.join(" ")), KAMAL.config.proxy_options_file
62+
if boot_options != proxy_boot_config.default_boot_options
63+
upload! StringIO.new(boot_options.join(" ")), proxy_boot_config.options_file
5564
else
5665
execute *KAMAL.proxy.reset_boot_options, raise_on_non_zero_exit: false
5766
end
5867

59-
if image != KAMAL.config.proxy_image_default
60-
upload! StringIO.new(image), KAMAL.config.proxy_image_file
68+
if image != proxy_boot_config.image_default
69+
upload! StringIO.new(image), proxy_boot_config.image_file
6170
else
6271
execute *KAMAL.proxy.reset_image, raise_on_non_zero_exit: false
6372
end
6473

6574
if image_version
66-
upload! StringIO.new(image_version), KAMAL.config.proxy_image_version_file
75+
upload! StringIO.new(image_version), proxy_boot_config.image_version_file
6776
else
6877
execute *KAMAL.proxy.reset_image_version, raise_on_non_zero_exit: false
6978
end
79+
80+
if run_command
81+
upload! StringIO.new(run_command), proxy_boot_config.run_command_file
82+
else
83+
execute *KAMAL.proxy.reset_run_command, raise_on_non_zero_exit: false
84+
end
7085
end
7186
when "get"
7287

@@ -78,6 +93,7 @@ def boot_config(subcommand)
7893
execute *KAMAL.proxy.reset_boot_options, raise_on_non_zero_exit: false
7994
execute *KAMAL.proxy.reset_image, raise_on_non_zero_exit: false
8095
execute *KAMAL.proxy.reset_image_version, raise_on_non_zero_exit: false
96+
execute *KAMAL.proxy.reset_run_command, raise_on_non_zero_exit: false
8197
end
8298
else
8399
raise ArgumentError, "Unknown boot_config subcommand #{subcommand}"
@@ -101,6 +117,7 @@ def reboot
101117
"Stopping and removing kamal-proxy on #{host}, if running..."
102118
execute *KAMAL.proxy.stop, raise_on_non_zero_exit: false
103119
execute *KAMAL.proxy.remove_container
120+
execute *KAMAL.proxy.ensure_apps_config_directory
104121

105122
execute *KAMAL.proxy.run
106123

lib/kamal/cli/templates/sample_hooks/post-deploy.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# KAMAL_PERFORMER
88
# KAMAL_VERSION
99
# KAMAL_HOSTS
10-
# KAMAL_ROLE (if set)
10+
# KAMAL_ROLES (if set)
1111
# KAMAL_DESTINATION (if set)
1212
# KAMAL_RUNTIME
1313

lib/kamal/cli/templates/sample_hooks/pre-build.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# KAMAL_PERFORMER
1414
# KAMAL_VERSION
1515
# KAMAL_HOSTS
16-
# KAMAL_ROLE (if set)
16+
# KAMAL_ROLES (if set)
1717
# KAMAL_DESTINATION (if set)
1818

1919
if [ -n "$(git status --porcelain)" ]; then

lib/kamal/cli/templates/sample_hooks/pre-connect.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# KAMAL_PERFORMER
1010
# KAMAL_VERSION
1111
# KAMAL_HOSTS
12-
# KAMAL_ROLE (if set)
12+
# KAMAL_ROLES (if set)
1313
# KAMAL_DESTINATION (if set)
1414
# KAMAL_RUNTIME
1515

lib/kamal/cli/templates/sample_hooks/pre-deploy.sample

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# KAMAL_HOSTS
1414
# KAMAL_COMMAND
1515
# KAMAL_SUBCOMMAND
16-
# KAMAL_ROLE (if set)
16+
# KAMAL_ROLES (if set)
1717
# KAMAL_DESTINATION (if set)
1818

1919
# Only check the build status for production deployments
@@ -82,11 +82,12 @@ end
8282

8383
$stdout.sync = true
8484

85-
puts "Checking build status..."
86-
attempts = 0
87-
checks = GithubStatusChecks.new
88-
8985
begin
86+
puts "Checking build status..."
87+
88+
attempts = 0
89+
checks = GithubStatusChecks.new
90+
9091
loop do
9192
case checks.state
9293
when "success"

0 commit comments

Comments
 (0)