diff --git a/lib/kamal/commands/accessory.rb b/lib/kamal/commands/accessory.rb index 552a5c3bf..281b87138 100644 --- a/lib/kamal/commands/accessory.rb +++ b/lib/kamal/commands/accessory.rb @@ -1,5 +1,5 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base - include Kamal::Commands::Proxy::Exec + include Proxy attr_reader :accessory_config delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd, @@ -111,10 +111,6 @@ def ensure_env_directory end private - def proxy_deploy_command_args(target:) - proxy.deploy_command_args(target: target) - end - def service_filter [ "--filter", "label=service=#{service_name}" ] end diff --git a/lib/kamal/commands/proxy/exec.rb b/lib/kamal/commands/accessory/proxy.rb similarity index 71% rename from lib/kamal/commands/proxy/exec.rb rename to lib/kamal/commands/accessory/proxy.rb index ac6f30a9b..195a321bf 100644 --- a/lib/kamal/commands/proxy/exec.rb +++ b/lib/kamal/commands/accessory/proxy.rb @@ -1,8 +1,8 @@ -module Kamal::Commands::Proxy::Exec +module Kamal::Commands::Accessory::Proxy delegate :proxy_container_name, to: :config def deploy(target:) - proxy_exec :deploy, service_name, *proxy_deploy_command_args(target: target) + proxy_exec :deploy, service_name, *proxy.deploy_command_args(target: target) end def remove diff --git a/lib/kamal/commands/app.rb b/lib/kamal/commands/app.rb index 5bbbdb516..6c4df0e4a 100644 --- a/lib/kamal/commands/app.rb +++ b/lib/kamal/commands/app.rb @@ -1,5 +1,5 @@ class Kamal::Commands::App < Kamal::Commands::Base - include Assets, Containers, Execution, Images, Logging, Kamal::Commands::Proxy::Exec + include Assets, Containers, Execution, Images, Logging, Proxy ACTIVE_DOCKER_STATUSES = [ :running, :restarting ] @@ -76,14 +76,6 @@ def ensure_env_directory end private - def service_name - role.container_prefix - end - - def proxy_deploy_command_args(target:) - role.proxy.deploy_command_args(target: target) - end - def latest_image_id docker :image, :ls, *argumentize("--filter", "reference=#{config.latest_image}"), "--format", "'{{.ID}}'" end diff --git a/lib/kamal/commands/app/proxy.rb b/lib/kamal/commands/app/proxy.rb new file mode 100644 index 000000000..777a4aaf5 --- /dev/null +++ b/lib/kamal/commands/app/proxy.rb @@ -0,0 +1,16 @@ +module Kamal::Commands::App::Proxy + delegate :proxy_container_name, to: :config + + def deploy(target:) + proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target) + end + + def remove + proxy_exec :remove, role.container_prefix + end + + private + def proxy_exec(*command) + docker :exec, proxy_container_name, "kamal-proxy", *command + end +end