Trim long hostnames

Hostnames longer than 64 characters are not supported by docker
This commit is contained in:
André Falk
2024-04-07 18:59:51 +02:00
parent 31669d4dce
commit 63c47eca4c
3 changed files with 30 additions and 1 deletions

View File

@@ -47,7 +47,8 @@ class Kamal::Cli::App::Boot
def start_new_version
audit "Booted app version #{version}"
execute *app.tie_cord(role.cord_host_file) if uses_cord?
execute *app.run(hostname: "#{host}-#{SecureRandom.hex(6)}")
hostname = "#{host.to_s[0...51].gsub(/\.+$/, '')}-#{SecureRandom.hex(6)}"
execute *app.run(hostname: hostname)
Kamal::Cli::Healthcheck::Poller.wait_for_healthy(pause_after_ready: true) { capture_with_info(*app.status(version: version)) }
end