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

@@ -236,6 +236,26 @@ class CliAppTest < CliTestCase
end
end
test "long hostname" do
stub_running
hostname = "this-hostname-is-really-unacceptably-long-to-be-honest.example.com"
stdouted { Kamal::Cli::App.start([ "boot", "-c", "test/fixtures/deploy_with_uncommon_hostnames.yml", "--hosts", hostname ]) }.tap do |output|
assert_match /docker run --detach --restart unless-stopped --name app-web-latest --hostname this-hostname-is-really-unacceptably-long-to-be-hon-[0-9a-f]{12} /, output
end
end
test "hostname is trimmed if will end with a period" do
stub_running
hostname = "this-hostname-with-random-part-is-too-long.example.com"
stdouted { Kamal::Cli::App.start([ "boot", "-c", "test/fixtures/deploy_with_uncommon_hostnames.yml", "--hosts", hostname ]) }.tap do |output|
assert_match /docker run --detach --restart unless-stopped --name app-web-latest --hostname this-hostname-with-random-part-is-too-long.example-[0-9a-f]{12} /, output
end
end
private
def run_command(*command, config: :with_accessories)
stdouted { Kamal::Cli::App.start([ *command, "-c", "test/fixtures/deploy_#{config}.yml", "--hosts", "1.1.1.1" ]) }

View File

@@ -0,0 +1,8 @@
service: app
image: dhh/app
servers:
- "this-hostname-with-random-part-is-too-long.example.com"
- "this-hostname-is-really-unacceptably-long-to-be-honest.example.com"
registry:
username: user
password: pw