diff --git a/plugins/caddy-vhosts/docker-args-process-deploy b/plugins/caddy-vhosts/docker-args-process-deploy index d79c3ef73e7..79d8719440d 100755 --- a/plugins/caddy-vhosts/docker-args-process-deploy +++ b/plugins/caddy-vhosts/docker-args-process-deploy @@ -75,6 +75,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() { app_domains="$(plugn trigger domains-list "$APP")" if [[ -n "$app_domains" ]]; then caddy_domains="$(echo "$app_domains" | xargs)" + caddy_domains="${caddy_domains// /, }" fi # add the labels for caddy here @@ -100,7 +101,7 @@ trigger-caddy-vhosts-docker-args-process-deploy() { letsencrypt_email="$(fn-caddy-letsencrypt-email)" scheme="http" if [[ -n "$letsencrypt_email" ]] && [[ "$has_443_mapping" == "true" ]]; then - output="--label caddy=${caddy_domains}" + output="--label 'caddy=${caddy_domains}'" scheme="https" if [[ -z "$proxy_container_https_port" ]]; then warning_scheme="$(awk -F ':' '{ print $1 }' <<<"$ssl_warning_mapping")" @@ -111,8 +112,8 @@ trigger-caddy-vhosts-docker-args-process-deploy() { output="$output --label \"caddy.reverse_proxy={{ upstreams $proxy_container_https_port }}\"" elif [[ -n "$proxy_container_http_port" ]] || [[ -n "$proxy_container_http_port_candidate" ]]; then - caddy_domains="${caddy_domains// /:80 }" - output="--label caddy=${caddy_domains}:80" + caddy_domains="${caddy_domains//, /:80, }" + output="--label 'caddy=${caddy_domains}:80'" if [[ -z "$proxy_container_http_port" ]]; then dokku_log_warn "Warning: http:80 port mapping not found" dokku_log_warn "Utilizing first http port mapping, http:$proxy_host_http_port_candidate:$proxy_container_http_port_candidate" diff --git a/plugins/caddy-vhosts/help-functions b/plugins/caddy-vhosts/help-functions index ce2276420c8..287ffed0455 100755 --- a/plugins/caddy-vhosts/help-functions +++ b/plugins/caddy-vhosts/help-functions @@ -6,7 +6,7 @@ cmd-caddy-help() { declare desc="help command" declare CMD="$1" local plugin_name="caddy" - local plugin_description="Manage mounted volumes" + local plugin_description="Manage the caddy proxy integration" if [[ "$CMD" == "${plugin_name}:help" ]]; then echo -e "Usage: dokku ${plugin_name}[:COMMAND]" diff --git a/plugins/traefik-vhosts/docker-args-process-deploy b/plugins/traefik-vhosts/docker-args-process-deploy index 93572ead198..9b46c9af866 100755 --- a/plugins/traefik-vhosts/docker-args-process-deploy +++ b/plugins/traefik-vhosts/docker-args-process-deploy @@ -91,6 +91,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { output="$output --label traefik.http.services.$APP-$PROC_TYPE.loadbalancer.server.port=$proxy_container_http_port" output="$output --label traefik.http.routers.$APP-$PROC_TYPE.entrypoints=http" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE.service=$APP-$PROC_TYPE" if [[ -n "$traefik_domains" ]]; then output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE.rule=Host(\\\`$traefik_domains\\\`)\"" echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path" @@ -107,6 +108,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.service=$APP-$PROC_TYPE-https" if [[ -n "$traefik_domains" ]]; then output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-https.rule=Host(\\\`$traefik_domains\\\`)\"" echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path" diff --git a/plugins/traefik-vhosts/help-functions b/plugins/traefik-vhosts/help-functions index 838b0b9601b..22ec4c1a857 100755 --- a/plugins/traefik-vhosts/help-functions +++ b/plugins/traefik-vhosts/help-functions @@ -6,7 +6,7 @@ cmd-traefik-help() { declare desc="help command" declare CMD="$1" local plugin_name="traefik" - local plugin_description="Manage mounted volumes" + local plugin_description="Manage the traefik proxy integration" if [[ "$CMD" == "${plugin_name}:help" ]]; then echo -e "Usage: dokku ${plugin_name}[:COMMAND]" diff --git a/plugins/traefik-vhosts/templates/compose.yml.sigil b/plugins/traefik-vhosts/templates/compose.yml.sigil index bd64d20df51..f8b9c0f54ed 100644 --- a/plugins/traefik-vhosts/templates/compose.yml.sigil +++ b/plugins/traefik-vhosts/templates/compose.yml.sigil @@ -17,7 +17,7 @@ services: - --log.format=json {{ if $.TRAEFIK_LETSENCRYPT_EMAIL }} - - --certificatesresolvers.leresolver.acme.caserver={{ $.TRAEFIK_LETSENCRYPT_SERVER }}" + - --certificatesresolvers.leresolver.acme.caserver={{ $.TRAEFIK_LETSENCRYPT_SERVER }} - --certificatesresolvers.leresolver.acme.email={{ $.TRAEFIK_LETSENCRYPT_EMAIL }} - --certificatesresolvers.leresolver.acme.storage=/acme.json - --certificatesresolvers.leresolver.acme.tlschallenge=true diff --git a/tests/unit/caddy.bats b/tests/unit/caddy.bats new file mode 100644 index 00000000000..91665f690cf --- /dev/null +++ b/tests/unit/caddy.bats @@ -0,0 +1,83 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + dokku nginx:stop + dokku caddy:start + create_app +} + +teardown() { + global_teardown + destroy_app + dokku caddy:stop + dokku nginx:start +} + +@test "(caddy) caddy:help" { + run /bin/bash -c "dokku caddy" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the caddy proxy integration" + help_output="$output" + + run /bin/bash -c "dokku caddy:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the caddy proxy integration" + assert_output "$help_output" +} + +@test "(caddy) single domain" { + run /bin/bash -c "dokku proxy:set $TEST_APP caddy" + echo "output: $output" + echo "status: $status" + assert_success + + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "curl --silent $(dokku url $TEST_APP)" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "python/http.server" +} + +@test "(caddy) multiple domains" { + run /bin/bash -c "dokku proxy:set $TEST_APP caddy" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP-2.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "curl --silent $TEST_APP.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "python/http.server" + + run /bin/bash -c "curl --silent $TEST_APP-2.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "python/http.server" +} diff --git a/tests/unit/traefik.bats b/tests/unit/traefik.bats new file mode 100644 index 00000000000..a37624afbf8 --- /dev/null +++ b/tests/unit/traefik.bats @@ -0,0 +1,83 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + dokku nginx:stop + dokku traefik:start + create_app +} + +teardown() { + global_teardown + destroy_app + dokku traefik:stop + dokku nginx:start +} + +@test "(traefik) traefik:help" { + run /bin/bash -c "dokku traefik" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the traefik proxy integration" + help_output="$output" + + run /bin/bash -c "dokku traefik:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the traefik proxy integration" + assert_output "$help_output" +} + +@test "(traefik) single domain" { + run /bin/bash -c "dokku proxy:set $TEST_APP traefik" + echo "output: $output" + echo "status: $status" + assert_success + + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "curl --silent $(dokku url $TEST_APP)" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "python/http.server" +} + +@test "(traefik) multiple domains" { + run /bin/bash -c "dokku proxy:set $TEST_APP traefik" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP-2.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "curl --silent $TEST_APP.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "python/http.server" + + run /bin/bash -c "curl --silent $TEST_APP-2.dokku.me" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "python/http.server" +}