Skip to content

Commit

Permalink
Boot accessories after pre-deploy hook
Browse files Browse the repository at this point in the history
That allows you to set proxy config in the hook before booting
the proxy.
  • Loading branch information
djmb committed Jan 17, 2025
1 parent 4ffa772 commit 1db44c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 5 additions & 7 deletions lib/kamal/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ def setup
say "Ensure Docker is installed...", :magenta
invoke "kamal:cli:server:bootstrap", [], invoke_options

say "Ensure kamal-proxy is running...", :magenta
invoke "kamal:cli:proxy:boot", [], invoke_options

invoke "kamal:cli:accessory:boot", [ "all" ], invoke_options
deploy(boot_proxy: false)
deploy(boot_accessories: true)
end
end
end

desc "deploy", "Deploy app to servers"
option :skip_push, aliases: "-P", type: :boolean, default: false, desc: "Skip image build and push"
def deploy(boot_proxy: true)
def deploy(boot_accessories: false)
runtime = print_runtime do
invoke_options = deploy_options

Expand All @@ -39,7 +35,9 @@ def deploy(boot_proxy: true)
run_hook "pre-deploy", secrets: true

say "Ensure kamal-proxy is running...", :magenta
invoke "kamal:cli:proxy:boot", [], invoke_options if boot_proxy
invoke "kamal:cli:proxy:boot", [], invoke_options

invoke "kamal:cli:accessory:boot", [ "all" ], invoke_options if boot_accessories

say "Detect stale containers...", :magenta
invoke "kamal:cli:app:stale_containers", [], invoke_options.merge(stop: true)
Expand Down
4 changes: 1 addition & 3 deletions test/cli/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class CliMainTest < CliTestCase
invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml", "version" => "999", "skip_hooks" => false }

Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:server:bootstrap", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:boot", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:boot", [ "all" ], invoke_options)
Kamal::Cli::Main.any_instance.expects(:deploy)
Kamal::Cli::Main.any_instance.expects(:deploy).with(boot_accessories: true)

run_command("setup").tap do |output|
assert_match /Ensure Docker is installed.../, output
Expand Down

0 comments on commit 1db44c4

Please sign in to comment.