Added network_args to proxy configuration

This commit is contained in:
Igor Alexandrov
2024-10-01 14:40:34 +04:00
parent f04cae529a
commit c917dd82cf
2 changed files with 10 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
def run
docker :run,
"--name", container_name,
"--network", "kamal",
*config.network_args,
"--detach",
"--restart", "unless-stopped",
"--volume", "kamal-proxy-config:/home/kamal-proxy/.config/kamal-proxy",

View File

@@ -3,6 +3,7 @@ class Kamal::Configuration::Proxy
DEFAULT_LOG_REQUEST_HEADERS = [ "Cache-Control", "Last-Modified", "User-Agent" ]
CONTAINER_NAME = "kamal-proxy"
NETWORK = "kamal"
delegate :argumentize, :optionize, to: Kamal::Utils
@@ -51,6 +52,10 @@ class Kamal::Configuration::Proxy
optionize ({ target: "#{target}:#{app_port}" }).merge(deploy_options), with: "="
end
def network_args
argumentize "--network", network
end
def merge(other)
self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config)
end
@@ -59,4 +64,8 @@ class Kamal::Configuration::Proxy
def seconds_duration(value)
value ? "#{value}s" : nil
end
def network
proxy_config["network"] || NETWORK
end
end