From f1297887993435ff07f606fd23f0d3f5afe4b0ca Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Fri, 27 Oct 2023 08:53:02 -0700 Subject: [PATCH 1/3] Enable aliases for more DRY with roles. --- lib/kamal/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index fc881c069..7cbe177c8 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -25,7 +25,7 @@ def load_config_files(*files) def load_config_file(file) if file.exist? - YAML.load(ERB.new(IO.read(file)).result).symbolize_keys + YAML.load(ERB.new(IO.read(file)).result, aliases: true).symbolize_keys else raise "Configuration file not found in #{file}" end From 6a3aea63010d0e100d27d179a1f362875080120e Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Fri, 27 Oct 2023 09:31:55 -0700 Subject: [PATCH 2/3] Support running without a :web role. Just pick the first one running traefik. --- lib/kamal/commands/healthcheck.rb | 2 +- lib/kamal/configuration.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kamal/commands/healthcheck.rb b/lib/kamal/commands/healthcheck.rb index 5adc02445..f7bc867d2 100644 --- a/lib/kamal/commands/healthcheck.rb +++ b/lib/kamal/commands/healthcheck.rb @@ -1,7 +1,7 @@ class Kamal::Commands::Healthcheck < Kamal::Commands::Base def run - web = config.role(:web) + web = config.role(:web) || config.roles.select(&:running_traefik?).first docker :run, "--detach", diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index 7cbe177c8..a8e1ae749 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -90,7 +90,7 @@ def all_hosts end def primary_web_host - role(:web).primary_host + (role(:web) || roles.select(&:running_traefik?).first).primary_host end def traefik_hosts From 7b781d2e2c95717349e55d41c2c32f05902a474d Mon Sep 17 00:00:00 2001 From: Matthew Kent Date: Fri, 27 Oct 2023 10:24:24 -0700 Subject: [PATCH 3/3] Don't block on empty roles, they're harmless. --- lib/kamal/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index a8e1ae749..2ba442601 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -249,7 +249,7 @@ def ensure_required_keys_present roles.each do |role| if role.hosts.empty? - raise ArgumentError, "No servers specified for the #{role.name} role" + puts "Warning: No servers specified for the #{role.name} role" end end