Added commands to deploy accessory to kamal-proxy

This commit is contained in:
Igor Alexandrov
2024-10-31 10:50:48 +04:00
parent b9804a07aa
commit 70d2c71734
3 changed files with 34 additions and 2 deletions

View File

@@ -2,8 +2,10 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
attr_reader :accessory_config
delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd,
:network_args, :publish_args, :env_args, :volume_args, :label_args, :option_args,
:secrets_io, :secrets_path, :env_directory,
:secrets_io, :secrets_path, :env_directory, :running_proxy?,
to: :accessory_config
delegate :proxy_container_name, to: :config
def initialize(config, name:)
super(config)
@@ -38,6 +40,16 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
docker :ps, *service_filter
end
def deploy
target = container_id_for(container_name: service_name, only_running: true)
proxy_exec :deploy, service_name, *accessory_config.proxy.deploy_command_args(target: target) if target
end
def remove
target = container_id_for(container_name: service_name, only_running: true)
proxy_exec :remove, service_name, *accessory_config.proxy.remove_command_args(target: target) if target
end
def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
pipe \
@@ -110,4 +122,8 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
def service_filter
[ "--filter", "label=service=#{service_name}" ]
end
def proxy_exec(*command)
docker :exec, proxy_container_name, "kamal-proxy", *command
end
end