Merge pull request #8136 from dokku/8067-ports-reset
Do not reset manually set port mappings when upgrading dokku
This commit is contained in:
@@ -9,10 +9,34 @@ trigger-nginx-vhosts-pre-disable-vhost() {
|
||||
declare trigger="pre-disable-vhost"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT
|
||||
plugn trigger ports-clear "$APP"
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# only clear ports if they are port 80 or 443
|
||||
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
|
||||
ports_to_clear=()
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_PORT")
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_SSL_PORT")
|
||||
fi
|
||||
|
||||
if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
local PORT_MAPS=$(plugn trigger ports-get "$APP")
|
||||
for PORT_MAP in $PORT_MAPS; do
|
||||
if [[ "$PORT_MAP" == "http:80:"* ]] || [[ "$PORT_MAP" == "https:443:"* ]]; then
|
||||
plugn trigger ports-clear "$APP"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-pre-disable-vhost "$@"
|
||||
|
||||
@@ -9,10 +9,34 @@ trigger-nginx-vhosts-pre-enable-vhost() {
|
||||
declare trigger="pre-enable-vhost"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" == "nginx" ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" DOKKU_PROXY_PORT DOKKU_PROXY_SSL_PORT
|
||||
plugn trigger ports-clear "$APP"
|
||||
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# only clear ports if they are port 80 or 443
|
||||
local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT)
|
||||
local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT)
|
||||
|
||||
ports_to_clear=()
|
||||
if [[ "$PROXY_PORT" == "80" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_PORT")
|
||||
fi
|
||||
if [[ "$PROXY_SSL_PORT" == "443" ]]; then
|
||||
ports_to_clear+=("DOKKU_PROXY_SSL_PORT")
|
||||
fi
|
||||
|
||||
if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then
|
||||
DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}"
|
||||
fi
|
||||
|
||||
# clear ports if there is a mapping starting with http:80 or https:443
|
||||
local PORT_MAPS=$(plugn trigger ports-get "$APP")
|
||||
for PORT_MAP in $PORT_MAPS; do
|
||||
if [[ "$PORT_MAP" == "http:80:"* ]] || [[ "$PORT_MAP" == "https:443:"* ]]; then
|
||||
plugn trigger ports-clear "$APP"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
trigger-nginx-vhosts-pre-enable-vhost "$@"
|
||||
|
||||
@@ -294,3 +294,79 @@ teardown() {
|
||||
assert_success
|
||||
assert_output "http:3000:3000"
|
||||
}
|
||||
|
||||
@test "(ports) ports not reinitialized on upgrade" {
|
||||
run /bin/bash -c "dokku domains:clear-global"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku domains:disable $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ports:add $TEST_APP http:3001:3001"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku checks:disable $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku domains:report $TEST_APP --domains-global-enabled"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "false"
|
||||
|
||||
run /bin/bash -c "dokku git:from-image $TEST_APP louislam/uptime-kuma:2"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ports:report $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "http:3001:3001"
|
||||
|
||||
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map-detected"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "http:3001:3001"
|
||||
|
||||
run /bin/bash -c "dokku domains:report $TEST_APP --domains-global-enabled"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "false"
|
||||
|
||||
run /bin/bash -c "dokku domains:setup $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Global server virtual host not set, disabling app vhost"
|
||||
assert_output_not_contains "No port set, setting to random open high port"
|
||||
assert_output_not_contains "Random port"
|
||||
|
||||
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "http:3001:3001"
|
||||
|
||||
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map-detected"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "http:3001:3001"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user