Added commands to deploy accessory to kamal-proxy
This commit is contained in:
@@ -18,6 +18,7 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
|
|||||||
execute *accessory.ensure_env_directory
|
execute *accessory.ensure_env_directory
|
||||||
upload! accessory.secrets_io, accessory.secrets_path, mode: "0600"
|
upload! accessory.secrets_io, accessory.secrets_path, mode: "0600"
|
||||||
execute *accessory.run
|
execute *accessory.run
|
||||||
|
execute *accessory.deploy if accessory.running_proxy?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -75,6 +76,7 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
|
|||||||
on(hosts) do
|
on(hosts) do
|
||||||
execute *KAMAL.auditor.record("Started #{name} accessory"), verbosity: :debug
|
execute *KAMAL.auditor.record("Started #{name} accessory"), verbosity: :debug
|
||||||
execute *accessory.start
|
execute *accessory.start
|
||||||
|
execute *accessory.deploy if accessory.running_proxy?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -87,6 +89,7 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
|
|||||||
on(hosts) do
|
on(hosts) do
|
||||||
execute *KAMAL.auditor.record("Stopped #{name} accessory"), verbosity: :debug
|
execute *KAMAL.auditor.record("Stopped #{name} accessory"), verbosity: :debug
|
||||||
execute *accessory.stop, raise_on_non_zero_exit: false
|
execute *accessory.stop, raise_on_non_zero_exit: false
|
||||||
|
# execute *accessory.remove if accessory.running_proxy?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
|||||||
attr_reader :accessory_config
|
attr_reader :accessory_config
|
||||||
delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd,
|
delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd,
|
||||||
:network_args, :publish_args, :env_args, :volume_args, :label_args, :option_args,
|
: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
|
to: :accessory_config
|
||||||
|
delegate :proxy_container_name, to: :config
|
||||||
|
|
||||||
|
|
||||||
def initialize(config, name:)
|
def initialize(config, name:)
|
||||||
super(config)
|
super(config)
|
||||||
@@ -38,6 +40,16 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
|||||||
docker :ps, *service_filter
|
docker :ps, *service_filter
|
||||||
end
|
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)
|
def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
|
||||||
pipe \
|
pipe \
|
||||||
@@ -110,4 +122,8 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
|||||||
def service_filter
|
def service_filter
|
||||||
[ "--filter", "label=service=#{service_name}" ]
|
[ "--filter", "label=service=#{service_name}" ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def proxy_exec(*command)
|
||||||
|
docker :exec, proxy_container_name, "kamal-proxy", *command
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class Kamal::Configuration::Accessory
|
|||||||
|
|
||||||
delegate :argumentize, :optionize, to: Kamal::Utils
|
delegate :argumentize, :optionize, to: Kamal::Utils
|
||||||
|
|
||||||
attr_reader :name, :accessory_config, :env
|
attr_reader :name, :accessory_config, :env, :proxy
|
||||||
|
|
||||||
def initialize(name, config:)
|
def initialize(name, config:)
|
||||||
@name, @config, @accessory_config = name.inquiry, config, config.raw_config["accessories"][name]
|
@name, @config, @accessory_config = name.inquiry, config, config.raw_config["accessories"][name]
|
||||||
@@ -20,6 +20,8 @@ class Kamal::Configuration::Accessory
|
|||||||
config: accessory_config.fetch("env", {}),
|
config: accessory_config.fetch("env", {}),
|
||||||
secrets: config.secrets,
|
secrets: config.secrets,
|
||||||
context: "accessories/#{name}/env"
|
context: "accessories/#{name}/env"
|
||||||
|
|
||||||
|
# initialize_proxy if running_proxy?
|
||||||
end
|
end
|
||||||
|
|
||||||
def service_name
|
def service_name
|
||||||
@@ -106,6 +108,17 @@ class Kamal::Configuration::Accessory
|
|||||||
accessory_config["cmd"]
|
accessory_config["cmd"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def running_proxy?
|
||||||
|
@accessory_config["proxy"].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize_proxy
|
||||||
|
@proxy = Kamal::Configuration::Proxy.new \
|
||||||
|
config: config,
|
||||||
|
proxy_config: accessory_config["proxy"],
|
||||||
|
context: "accessories/#{name}/proxy"
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
attr_accessor :config
|
attr_accessor :config
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user