diff --git a/docs/deployment/application-management.md b/docs/deployment/application-management.md index b2a4eead9..421ae5ec7 100644 --- a/docs/deployment/application-management.md +++ b/docs/deployment/application-management.md @@ -149,7 +149,12 @@ dokku apps:clone node-js-app io-js-app Cloning node-js-app to io-js-app... done ``` -This will copy all of your app's contents into a new app directory with the name of your choice and then rebuild the new version of the app and deploy it. All of your config variables, including database urls, will be preserved. Custom domains and SSL certificates will not be copied to the new app. +This will copy all of your app's contents into a new app directory with the name of your choice and then rebuild the new version of the app and deploy it with the following caveats: + +- All of your environment variables, including database urls, will be preserved. +- Custom domains are not applied to the new app. +- SSL certificates will not be copied to the new app. +- Port mappings with the scheme `https` and host-port `443` will be skipped. > Warning: If you have exposed specific ports via docker-options, or performed anything that cannot be done against multiple applications, `apps:clone` may result in errors. diff --git a/plugins/certs/post-app-clone-setup b/plugins/certs/post-app-clone-setup index 77487ca0b..dcfe877ea 100755 --- a/plugins/certs/post-app-clone-setup +++ b/plugins/certs/post-app-clone-setup @@ -8,6 +8,7 @@ certs_post_app_clone_setup() { local APP_DIR="$DOKKU_ROOT/$NEW_APP" rm -rf "$APP_DIR/tls" + plugn trigger post-certs-remove "$NEW_APP" } certs_post_app_clone_setup "$@" diff --git a/plugins/nginx-vhosts/post-certs-remove b/plugins/proxy/post-certs-remove similarity index 54% rename from plugins/nginx-vhosts/post-certs-remove rename to plugins/proxy/post-certs-remove index 2fb2c9e10..d24c947a6 100755 --- a/plugins/nginx-vhosts/post-certs-remove +++ b/plugins/proxy/post-certs-remove @@ -5,16 +5,15 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions" -nginx_post_certs_remove() { +trigger-proxy-post-certs-remove() { declare desc="unset port config vars after SSL cert is removed" local trigger="nginx_post_certs_remove" local APP="$1" - if [[ "$(get_app_proxy_type "$APP")" == "nginx" ]]; then - config_unset --no-restart "$APP" DOKKU_PROXY_SSL_PORT - # shellcheck disable=SC2046 - remove_proxy_ports "$APP" $(filter_app_proxy_ports "$APP" "https" "443") - fi + config_unset --no-restart "$APP" DOKKU_PROXY_SSL_PORT + + # shellcheck disable=SC2046 + remove_proxy_ports "$APP" $(filter_app_proxy_ports "$APP" "https" "443") } -nginx_post_certs_remove "$@" +trigger-proxy-post-certs-remove "$@" diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index daf87f0d1..e92e07a2c 100755 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -146,6 +146,27 @@ teardown () { assert_success } +@test "(apps) apps:clone ssl-app" { + run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_PROXY_PORT_MAP=https:443:5000 DOKKU_PROXY_SSL_PORT=443" + deploy_app + run /bin/bash -c "dokku apps:clone $TEST_APP app-without-ssl" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku --quiet proxy:ports app-without-ssl | xargs" + echo "output: $output" + echo "status: $status" + assert_output "http 80 5000" + run /bin/bash -c "dokku config:get app-without-ssl DOKKU_PROXY_SSL_PORT" + echo "output: $output" + echo "status: $status" + assert_output "" + run /bin/bash -c "dokku --force apps:destroy app-without-ssl" + echo "output: $output" + echo "status: $status" + assert_success +} + @test "(apps) apps:clone --skip-deploy" { deploy_app run /bin/bash -c "dokku apps:clone --skip-deploy $TEST_APP great-test-name"