Merge pull request #3238 from dokku/josegonzalez-patch-2
Handle proxy issues in app renaming
This commit is contained in:
10 files changed
+79
-14
No files matched your search
@@ -373,6 +373,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `network-clear-config`
|
||||||
|
|
||||||
|
- Description: Clears network configuration
|
||||||
|
- Invoked by: `internally triggered by proxy-clear-config within proxy implementations`
|
||||||
|
- Arguments: `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
### `network-compute-ports`
|
### `network-compute-ports`
|
||||||
|
|
||||||
- Description: Computes the ports for a given app container
|
- Description: Computes the ports for a given app container
|
||||||
@@ -1040,6 +1055,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `proxy-clear-config`
|
||||||
|
|
||||||
|
- Description: Clears the proxy implementation configuration for a given app
|
||||||
|
- Invoked by: `internally triggered by apps:rename`
|
||||||
|
- Arguments: `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
### `proxy-enable`
|
### `proxy-enable`
|
||||||
|
|
||||||
- Description: Enables the configured proxy implementation for an app
|
- Description: Enables the configured proxy implementation for an app
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
hook
|
||||||
@@ -14,12 +14,13 @@ apps_rename_cmd() {
|
|||||||
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
|
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
|
||||||
local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache"
|
local OLD_CACHE_HOST_DIR="$DOKKU_HOST_ROOT/$OLD_APP/cache"
|
||||||
|
|
||||||
if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR"; then
|
if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR" > /dev/null 2>&1; then
|
||||||
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_HOST_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_HOST_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
||||||
fi
|
fi
|
||||||
rm -rf "$OLD_CACHE_DIR"
|
rm -rf "$OLD_CACHE_DIR"
|
||||||
apps_create "$NEW_APP"
|
apps_create "$NEW_APP"
|
||||||
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
|
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
|
||||||
|
plugn trigger proxy-clear-config "$NEW_APP"
|
||||||
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
|
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
|
||||||
[[ -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/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/VHOST" ]] && sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
|
||||||
|
|||||||
@@ -26,3 +26,9 @@ nginx_vhosts_help_cmd() {
|
|||||||
help_desc
|
help_desc
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nginx_clear_config() {
|
||||||
|
declare desc="Remove the nginx conf file"
|
||||||
|
declare APP="$1";
|
||||||
|
rm -f "$DOKKU_ROOT/$APP/nginx.conf"
|
||||||
|
}
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/internal-functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
|
||||||
|
|
||||||
|
trigger-nginx-vhosts-clear-config() {
|
||||||
|
declare desc="clear nginx config for proxy app containers from command line"
|
||||||
|
declare trigger="trigger-nginx-vhosts-clear-config"
|
||||||
|
declare APP="$1"
|
||||||
|
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||||
|
|
||||||
|
if [[ "$(get_app_proxy_type "$APP")" = "nginx" ]]; then
|
||||||
|
plugn trigger network-clear-config "$APP"
|
||||||
|
nginx_clear_config "$APP"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger-nginx-vhosts-clear-config "$@"
|
||||||
+14
-1
@@ -113,6 +113,19 @@ teardown () {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:rename with tls" {
|
||||||
|
setup_test_tls
|
||||||
|
deploy_app
|
||||||
|
run bash -c "dokku apps:rename $TEST_APP great-test-name"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
run bash -c "dokku --force apps:destroy great-test-name"
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
@test "(apps) apps:clone" {
|
@test "(apps) apps:clone" {
|
||||||
deploy_app
|
deploy_app
|
||||||
run bash -c "dokku apps:clone $TEST_APP great-test-name"
|
run bash -c "dokku apps:clone $TEST_APP great-test-name"
|
||||||
@@ -213,4 +226,4 @@ teardown () {
|
|||||||
assert_output "false"
|
assert_output "false"
|
||||||
|
|
||||||
destroy_app
|
destroy_app
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,6 @@ assert_urls() {
|
|||||||
assert_output < <(tr ' ' '\n' <<< "${urls}")
|
assert_output < <(tr ' ' '\n' <<< "${urls}")
|
||||||
}
|
}
|
||||||
|
|
||||||
build_nginx_config() {
|
|
||||||
# simulate nginx post-deploy
|
|
||||||
dokku domains:setup $TEST_APP
|
|
||||||
dokku nginx:build-config $TEST_APP
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) remove exited containers" {
|
@test "(core) remove exited containers" {
|
||||||
deploy_app
|
deploy_app
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ assert_url() {
|
|||||||
assert_output "${url}"
|
assert_output "${url}"
|
||||||
}
|
}
|
||||||
|
|
||||||
build_nginx_config() {
|
|
||||||
# simulate nginx post-deploy
|
|
||||||
dokku domains:setup $TEST_APP
|
|
||||||
dokku nginx:build-config $TEST_APP
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) run (with --options)" {
|
@test "(core) run (with --options)" {
|
||||||
deploy_app
|
deploy_app
|
||||||
run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version"
|
run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version"
|
||||||
|
|||||||
@@ -372,3 +372,9 @@ cat<<EOF > "$APP_REPO_DIR/nginx.conf.sigil"
|
|||||||
some lame nginx config
|
some lame nginx config
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_nginx_config() {
|
||||||
|
# simulate nginx post-deploy
|
||||||
|
dokku domains:setup "$TEST_APP"
|
||||||
|
dokku nginx:build-config "$TEST_APP"
|
||||||
|
}
|
||||||
Reference in new issue
Block a user