mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
feat: do not clone URLS and VHOST files to new apps
This follows the heroku pattern of ensuring applications are "freshly" created, routing-wise. Closes #2740
This commit is contained in:
@@ -149,9 +149,9 @@ 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.
|
||||
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.
|
||||
|
||||
> Warning: If you have exposed specific ports via docker-options, added generic domains, or performed anything that cannot be done against multiple applications, `apps:clone` may result in errors.
|
||||
> 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.
|
||||
|
||||
By default, Dokku will deploy this new application, though you can skip the deploy by using the `--skip-deploy` flag:
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ apps_clone_cmd() {
|
||||
|
||||
apps_create "$NEW_APP"
|
||||
pushd "$DOKKU_ROOT/$OLD_APP/." > /dev/null
|
||||
find ./* -not \( -name .cache \) | grep -v -e "./cache" -e "./tls" | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP"
|
||||
find ./* -not \( -name .cache \) | grep -v "./cache" | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP"
|
||||
popd > /dev/null 2>&1 || pushd "/tmp" > /dev/null
|
||||
plugn trigger post-app-clone-setup "$OLD_APP" "$NEW_APP"
|
||||
|
||||
@@ -46,8 +46,6 @@ apps_clone_cmd() {
|
||||
fi
|
||||
rm -rf "$NEW_CACHE_DIR"
|
||||
|
||||
[[ -f "$DOKKU_ROOT/$NEW_APP/URLS" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/URLS"
|
||||
[[ -f "$DOKKU_ROOT/$NEW_APP/VHOST" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
|
||||
[[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]] && sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive"
|
||||
[[ "$SKIP_REBUILD" == "true" ]] || ps_rebuild "$NEW_APP"
|
||||
plugn trigger post-app-clone "$OLD_APP" "$NEW_APP"
|
||||
|
||||
12
plugins/certs/post-app-clone-setup
Executable file
12
plugins/certs/post-app-clone-setup
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
certs_post_app_clone_setup() {
|
||||
declare desc="removes cert file when setting up a clone"
|
||||
declare OLD_APP="$1" NEW_APP="$2"
|
||||
local APP_DIR="$DOKKU_ROOT/$NEW_APP"
|
||||
|
||||
rm -rf "$APP_DIR/tls"
|
||||
}
|
||||
|
||||
certs_post_app_clone_setup "$@"
|
||||
12
plugins/domains/post-app-clone-setup
Executable file
12
plugins/domains/post-app-clone-setup
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
domains_post_app_clone_setup() {
|
||||
declare desc="removes domain files when setting up a clone"
|
||||
declare OLD_APP="$1" NEW_APP="$2"
|
||||
local APP_DIR="$DOKKU_ROOT/$NEW_APP"
|
||||
|
||||
rm -rf "$APP_DIR/URLS" "$APP_DIR/VHOST"
|
||||
}
|
||||
|
||||
domains_post_app_clone_setup "$@"
|
||||
@@ -152,6 +152,12 @@ teardown () {
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
run [ -d /home/dokku/great-test-name/tls ]
|
||||
assert_failure
|
||||
run [ -f /home/dokku/great-test-name/URLS ]
|
||||
assert_failure
|
||||
run [ -f /home/dokku/great-test-name/VHOST ]
|
||||
assert_failure
|
||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
|
||||
Reference in New Issue
Block a user