Fix /home/kamal-proxy/.config/kamal-proxy ownership

1. Update to kamal-proxy 0.4.0 which creates and chowns
/home/kamal-proxy/.config/kamal-proxy to kamal-proxy
2. Use a docker volume rather than mapping in a directory, so docker
keeps it owned by the correct user
This commit is contained in:
Donal McBreen
2024-09-19 12:25:57 +01:00
parent a6b983de06
commit 1d7c9fec1d
8 changed files with 12 additions and 51 deletions

View File

@@ -167,7 +167,6 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
stop
remove_container
remove_image
remove_host_directory
end
end
end
@@ -192,16 +191,6 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
end
end
desc "remove_host_directory", "Remove proxy directory from servers", hide: true
def remove_host_directory
with_lock do
on(KAMAL.proxy_hosts) do
execute *KAMAL.auditor.record("Removed #{KAMAL.config.proxy_directory}"), verbosity: :debug
execute *KAMAL.proxy.remove_host_directory, raise_on_non_zero_exit: false
end
end
end
private
def removal_allowed?(force)
on(KAMAL.proxy_hosts) do |host|

View File

@@ -8,8 +8,7 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
"--detach",
"--restart", "unless-stopped",
*config.proxy_publish_args,
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
*config.proxy_config_volume.docker_args,
"--volume", "kamal-proxy-config:/home/kamal-proxy/.config/kamal-proxy",
*config.logging_args,
config.proxy_image
end
@@ -57,10 +56,6 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"
end
def remove_host_directory
remove_directory config.proxy_directory
end
def cleanup_traefik
chain \
docker(:container, :stop, "traefik"),

View File

@@ -14,7 +14,7 @@ class Kamal::Configuration
include Validation
PROXY_MINIMUM_VERSION = "v0.3.0"
PROXY_MINIMUM_VERSION = "v0.4.0"
PROXY_HTTP_PORT = 80
PROXY_HTTPS_PORT = 443
@@ -216,10 +216,6 @@ class Kamal::Configuration
File.join apps_directory, [ service, destination ].compact.join("-")
end
def proxy_directory
File.join run_directory, "proxy"
end
def env_directory
File.join app_directory, "env"
end
@@ -262,12 +258,6 @@ class Kamal::Configuration
"kamal-proxy"
end
def proxy_config_volume
Kamal::Configuration::Volume.new \
host_path: File.join(proxy_directory, "config"),
container_path: "/home/kamal-proxy/.config/kamal-proxy"
end
def to_h
{