diff --git a/plugins/apps/pre-delete b/plugins/apps/pre-delete index d1fc39ed5..8fe4e5fe2 100755 --- a/plugins/apps/pre-delete +++ b/plugins/apps/pre-delete @@ -8,6 +8,10 @@ apps_pre_delete() { local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG"); local CACHE_DIR="$DOKKU_ROOT/$APP/cache" verify_app_name "$APP" + if ! is_image_herokuish_based "$IMAGE"; then + return + fi + if [[ -d $CACHE_DIR ]]; then docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$CACHE_DIR:/cache" "$IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true fi diff --git a/plugins/common/functions b/plugins/common/functions index b7e586381..476422fe3 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -985,6 +985,7 @@ get_container_ports() { get_app_urls() { declare desc="print an app's available urls" + source "$PLUGIN_AVAILABLE_PATH/certs/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/domains/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" @@ -1015,7 +1016,11 @@ get_app_urls() { local URLS="$(merge_dedupe_list "$port_urls $app_urls" " ")" case "$1" in url) - echo "$URLS" | tr ' ' '\n' | head -n1 + if is_ssl_enabled "$APP"; then + echo "$URLS" | tr ' ' '\n' | grep https | head -n1 + else + echo "$URLS" | tr ' ' '\n' | head -n1 + fi ;; urls) echo "$URLS" | tr ' ' '\n' | sort diff --git a/tests/unit/40_core_2.bats b/tests/unit/40_core_2.bats index 561901491..479b02213 100644 --- a/tests/unit/40_core_2.bats +++ b/tests/unit/40_core_2.bats @@ -22,6 +22,15 @@ assert_urls() { assert_output < <(tr ' ' '\n' <<< "${urls}" | sort) } +assert_url() { + url=$1 + run dokku url $TEST_APP + echo "output: "$output + echo "status: "$status + echo "url: ${url}" + assert_output "${url}" +} + build_nginx_config() { # simulate nginx post-deploy dokku domains:setup $TEST_APP @@ -64,6 +73,13 @@ build_nginx_config() { assert_urls "http://test.dokku.me" "http://${TEST_APP}.dokku.me" "https://test.dokku.me" "https://${TEST_APP}.dokku.me" } +@test "(core) url (app ssl)" { + setup_test_tls + assert_url "https://dokku.me" + build_nginx_config + assert_url "https://${TEST_APP}.dokku.me" +} + @test "(core) urls (wildcard ssl)" { setup_test_tls wildcard assert_urls "https://dokku.me"