Default to keeping 10m of proxy logs

Match the defaults for the application containers of 10m of logs.

Allow them to be altered with the proxy boot_config set command.
This commit is contained in:
Donal McBreen
2024-10-07 16:20:40 -04:00
parent e34031f70c
commit 67ce1912f7
4 changed files with 31 additions and 15 deletions

View File

@@ -25,12 +25,14 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
option :publish, type: :boolean, default: true, desc: "Publish the proxy ports on the host"
option :http_port, type: :numeric, default: Kamal::Configuration::PROXY_HTTP_PORT, desc: "HTTP port to publish on the host"
option :https_port, type: :numeric, default: Kamal::Configuration::PROXY_HTTPS_PORT, desc: "HTTPS port to publish on the host"
option :log_max_size, type: :string, default: Kamal::Configuration::PROXY_LOG_MAX_SIZE, desc: "Max size of proxy logs"
option :docker_options, type: :array, default: [], desc: "Docker options to pass to the proxy container", banner: "option=value option2=value2"
def boot_config(subcommand)
case subcommand
when "set"
boot_options = [
*(KAMAL.config.proxy_publish_args(options[:http_port], options[:https_port]) if options[:publish]),
*(KAMAL.config.proxy_logging_args(options[:log_max_size])),
*options[:docker_options].map { |option| "--#{option}" }
]

View File

@@ -17,6 +17,7 @@ class Kamal::Configuration
PROXY_MINIMUM_VERSION = "v0.7.0"
PROXY_HTTP_PORT = 80
PROXY_HTTPS_PORT = 443
PROXY_LOG_MAX_SIZE = "10m"
class << self
def create_from(config_file:, destination: nil, version: nil)
@@ -252,8 +253,12 @@ class Kamal::Configuration
argumentize "--publish", [ "#{http_port}:#{PROXY_HTTP_PORT}", "#{https_port}:#{PROXY_HTTPS_PORT}" ]
end
def proxy_logging_args(max_size)
argumentize "--log-opt", "max-size=#{max_size}"
end
def proxy_options_default
proxy_publish_args PROXY_HTTP_PORT, PROXY_HTTPS_PORT
[ *proxy_publish_args(PROXY_HTTP_PORT, PROXY_HTTPS_PORT), *proxy_logging_args(PROXY_LOG_MAX_SIZE) ]
end
def proxy_image