From dcd4778dd9470e34cb856c0d0509cadde71c403f Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Wed, 11 Sep 2024 14:22:37 +0100 Subject: [PATCH] Port -> app_port --- lib/kamal/commands/proxy.rb | 6 +++--- lib/kamal/configuration/docs/proxy.yml | 6 +++--- lib/kamal/configuration/proxy.rb | 4 ++-- test/cli/app_test.rb | 2 +- test/cli/proxy_test.rb | 2 +- test/commands/proxy_test.rb | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/kamal/commands/proxy.rb b/lib/kamal/commands/proxy.rb index b50cd0f2..42fe3524 100644 --- a/lib/kamal/commands/proxy.rb +++ b/lib/kamal/commands/proxy.rb @@ -1,6 +1,6 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base delegate :argumentize, :optionize, to: Kamal::Utils - delegate :container_name, :port, to: :proxy_config + delegate :container_name, :app_port, to: :proxy_config attr_reader :proxy_config @@ -35,11 +35,11 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base end def deploy(service, target:) - docker :exec, container_name, "kamal-proxy", :deploy, service, *optionize({ target: "#{target}:#{port}" }), *proxy_config.deploy_command_args + docker :exec, container_name, "kamal-proxy", :deploy, service, *optionize({ target: "#{target}:#{app_port}" }), *proxy_config.deploy_command_args end def remove(service, target:) - docker :exec, container_name, "kamal-proxy", :remove, service, *optionize({ target: "#{target}:#{port}" }) + docker :exec, container_name, "kamal-proxy", :remove, service, *optionize({ target: "#{target}:#{app_port}" }) end def info diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index c30117fb..906d4032 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -56,11 +56,11 @@ proxy: # requests for other apps that do have a host set. host: foo.example.com - # Port + # App port # - # The port the application is exposed on + # The port the application container is exposed on # Defaults to 80 - port: 3000 + app_port: 3000 # SSL # diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index db3dcd96..32abc382 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -25,8 +25,8 @@ class Kamal::Configuration::Proxy end end - def port - proxy_config.fetch("port", 80) + def app_port + proxy_config.fetch("app_port", 80) end def image diff --git a/test/cli/app_test.rb b/test/cli/app_test.rb index 17ae3deb..4460390e 100644 --- a/test/cli/app_test.rb +++ b/test/cli/app_test.rb @@ -363,7 +363,7 @@ class CliAppTest < CliTestCase assert_match /Renaming container .* to .* as already deployed on 1.1.1.1/, output # Rename assert_match /docker rename app-web-latest app-web-latest_replaced_[0-9a-f]{16}/, output assert_match /docker run --detach --restart unless-stopped --name app-web-latest --network kamal --hostname 1.1.1.1-[0-9a-f]{12} -e KAMAL_CONTAINER_NAME="app-web-latest" -e KAMAL_VERSION="latest" --env-file .kamal\/env\/roles\/app-web.env --log-opt max-size="10m" --label service="app" --label role="web" --label destination dhh\/app:latest/, output - assert_match /docker exec kamal-proxy kamal-proxy deploy app-web --target "123:3000"/, output + assert_match /docker exec kamal-proxy kamal-proxy deploy app-web --target "123:80"/, output assert_match "docker container ls --all --filter name=^app-web-123$ --quiet | xargs docker stop", output end end diff --git a/test/cli/proxy_test.rb b/test/cli/proxy_test.rb index 3d65207c..b4d5aa78 100644 --- a/test/cli/proxy_test.rb +++ b/test/cli/proxy_test.rb @@ -25,7 +25,7 @@ class CliProxyTest < CliTestCase assert_match "docker container prune --force --filter label=org.opencontainers.image.title=kamal-proxy on 1.1.1.1", output assert_match "docker container prune --force --filter label=org.opencontainers.image.title=Traefik on 1.1.1.1", output assert_match "docker run --name kamal-proxy --network kamal --detach --restart unless-stopped --publish 80:80 --publish 443:443 --volume /var/run/docker.sock:/var/run/docker.sock --volume kamal-proxy:/root/.config/kamal-proxy --log-opt max-size=\"10m\" #{Kamal::Configuration::Proxy::DEFAULT_IMAGE} on 1.1.1.1", output - assert_match "docker exec kamal-proxy kamal-proxy deploy app-web --target \"abcdefabcdef:3000\" --deploy-timeout \"6s\" --buffer-requests --buffer-responses --log-request-header \"Cache-Control\" --log-request-header \"Last-Modified\" on 1.1.1.1", output + assert_match "docker exec kamal-proxy kamal-proxy deploy app-web --target \"abcdefabcdef:80\" --deploy-timeout \"6s\" --buffer-requests --buffer-responses --log-request-header \"Cache-Control\" --log-request-header \"Last-Modified\" on 1.1.1.1", output assert_match "docker container stop kamal-proxy on 1.1.1.2", output assert_match "docker container stop traefik on 1.1.1.2", output diff --git a/test/commands/proxy_test.rb b/test/commands/proxy_test.rb index 71bb4f1c..f5e82a34 100644 --- a/test/commands/proxy_test.rb +++ b/test/commands/proxy_test.rb @@ -109,13 +109,13 @@ class CommandsProxyTest < ActiveSupport::TestCase test "deploy" do assert_equal \ - "docker exec kamal-proxy kamal-proxy deploy service --target \"172.1.0.2:3000\" --buffer-requests --buffer-responses --log-request-header \"Cache-Control\" --log-request-header \"Last-Modified\"", + "docker exec kamal-proxy kamal-proxy deploy service --target \"172.1.0.2:80\" --buffer-requests --buffer-responses --log-request-header \"Cache-Control\" --log-request-header \"Last-Modified\"", new_command.deploy("service", target: "172.1.0.2").join(" ") end test "remove" do assert_equal \ - "docker exec kamal-proxy kamal-proxy remove service --target \"172.1.0.2:3000\"", + "docker exec kamal-proxy kamal-proxy remove service --target \"172.1.0.2:80\"", new_command.remove("service", target: "172.1.0.2").join(" ") end