Use version 0.1.0 of kamal-proxy and add minimum version check

This commit is contained in:
Donal McBreen
2024-09-16 15:51:58 +01:00
parent 6c51e596ae
commit 1f721739d6
8 changed files with 69 additions and 12 deletions

View File

@@ -10,6 +10,12 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
on(KAMAL.proxy_hosts) do |host|
execute *KAMAL.registry.login
version = capture_with_info(*KAMAL.proxy.version).strip.presence
if version && Kamal::Utils.older_version?(version, Kamal::Configuration::Proxy::MINIMUM_VERSION)
raise "kamal-proxy version #{version} is too old, please reboot to update to at least #{Kamal::Configuration::Proxy::MINIMUM_VERSION}"
end
execute *KAMAL.proxy.start_or_run
end
end

View File

@@ -46,6 +46,12 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
docker :ps, "--filter", "name=^#{container_name}$"
end
def version
pipe \
docker(:inspect, container_name, "--format '{{.Config.Image}}'"),
[ :cut, "-d:", "-f2" ]
end
def logs(since: nil, lines: nil, grep: nil, grep_options: nil)
pipe \
docker(:logs, container_name, (" --since #{since}" if since), (" --tail #{lines}" if lines), "--timestamps", "2>&1"),

View File

@@ -1,9 +1,10 @@
class Kamal::Configuration::Proxy
include Kamal::Configuration::Validation
MINIMUM_VERSION = "v0.1.0"
DEFAULT_HTTP_PORT = 80
DEFAULT_HTTPS_PORT = 443
DEFAULT_IMAGE = "basecamp/kamal-proxy:latest"
DEFAULT_IMAGE = "basecamp/kamal-proxy:#{MINIMUM_VERSION}"
DEFAULT_LOG_REQUEST_HEADERS = [ "Cache-Control", "Last-Modified", "User-Agent" ]
delegate :argumentize, :optionize, to: Kamal::Utils
@@ -62,7 +63,7 @@ class Kamal::Configuration::Proxy
def config_volume
Kamal::Configuration::Volume.new \
host_path: File.join(config.proxy_directory, "config"),
container_path: "/root/.config/kamal-proxy"
container_path: "/home/kamal-proxy/.config/kamal-proxy"
end
private

View File

@@ -101,4 +101,8 @@ module Kamal::Utils
arch
end
end
def older_version?(version, other_version)
Gem::Version.new(version.delete_prefix("v")) < Gem::Version.new(other_version.delete_prefix("v"))
end
end