Merge pull request #7442 from turicas/fix/domains-semantics

Update how domains:clear works and add domains:reset command
This commit is contained in:
Jose Diaz-Gonzalez
2025-07-02 02:26:11 -04:00
committed by GitHub
10 changed files with 37 additions and 8 deletions

View File

@@ -3,4 +3,5 @@
## Changes
- Process stop timeouts are now configured via the `ps` property `stop-timeout-seconds`. Existing `DOKKU_DOCKER_STOP_TIMEOUT` environment variables will be automatically migrated to the new value.
- Processes now default to a `30` second stop timeout.
- Processes now default to a `30` second stop timeout.
- The `domains:clear` command no longer runs domain setup after clearing the domains. Use `domains:reset` or run `domains:setup` manually to have the same effect.

View File

@@ -13,6 +13,7 @@ domains:enable <app> # Enable VHOST support
domains:remove <app> <domain> [<domain> ...] # Remove domains from app
domains:remove-global <domain> [<domain> ...] # Remove global domain names
domains:report [<app>|--global] [<flag>] # Displays a domains report for one or more apps
domains:reset <app> # Reset app domains to global-configured domains
domains:set <app> <domain> [<domain> ...] # Set domains for app
domains:set-global <domain> [<domain> ...] # Set global domain names
```
@@ -75,6 +76,9 @@ dokku domains:remove node-js-app dokku.me
# set all custom domains for app
dokku domains:set node-js-app dokku.me dokku.org
# delete all app domains and configure available global domains on it
dokku domains:reset node-js-app
```
## Displaying domains reports for an app

View File

@@ -1699,7 +1699,7 @@ curl "http://httpstat.us/200"
### `post-domains-update`
- Description: Allows you to run commands once the domain for an app has been updated. It also sends in the command that has been used. This can be "add", "clear" or "remove". The third argument will be the optional list of domains
- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove`, `dokku domains:set`
- Invoked by: `dokku domains:add`, `dokku domains:clear`, `dokku domains:remove`, `dokku domains:reset`, `dokku domains:set`
- Arguments: `$APP` `action name` `domains`
- Example:

View File

@@ -158,6 +158,8 @@ At this time, the following dokku commands are used to interact with a complete
- triggers: `pre-enable-vhost`
- `domains:remove`: Removes a domain from an app.
- triggers: `post-domains-update`
- `domains:reset`: Reset app domains to global-configured domains.
- triggers: `post-domains-update`
- `domains:set`: Sets all domains for a given app.
- triggers: `post-domains-update`
- `proxy:build-config`: Builds - or rebuilds - external proxy configuration.

View File

@@ -24,7 +24,6 @@ fn-domains-clear-app() {
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
rm -f "$APP_VHOST_PATH"
domains_setup "$APP"
plugn trigger post-domains-update "$APP" "clear"
dokku_log_info1 "Cleared domains in $APP"
}

View File

@@ -36,6 +36,7 @@ fn-help-content() {
domains:remove <app> <domain> [<domain> ...], Remove domains from app
domains:remove-global <domain> [<domain> ...], Remove global domain names
domains:report [<app>|--global] [<flag>], Displays a domains report for one or more apps
domains:reset <app>, Reset app domains to global-configured domains
domains:set <app> <domain> [<domain> ...], Set domains for app
domains:set-global <domain> [<domain> ...], Set global domain names
help_content

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-clear-global() {
declare desc="clear global domain names via command line"
declare desc="clear global domain names"
declare cmd="domains:clear-global"
[[ "$1" == "$cmd" ]] && shift 1

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
cmd-domains-reset() {
declare desc="reset app domains to global-configured domains"
declare cmd="domains:reset"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
fn-domains-clear "$APP"
domains_setup "$APP"
plugn trigger post-domains-update "$APP" "reset"
dokku_log_info1_quiet "Reset domains for $APP"
}
cmd-domains-reset "$@"

View File

@@ -12,6 +12,8 @@ cmd-domains-setup() {
verify_app_name "$APP"
domains_setup "$APP"
plugn trigger post-domains-update "$APP" "reset"
dokku_log_info1_quiet "Setup domains for $APP"
}
cmd-domains-setup "$@"

View File

@@ -188,7 +188,7 @@ teardown() {
assert_output_contains a--domain.with--hyphens
}
@test "(domains) domains:clear" {
@test "(domains) domains:reset" {
run /bin/bash -c "dokku domains:add $TEST_APP test.app.${DOKKU_DOMAIN}"
echo "output: $output"
echo "status: $status"
@@ -199,7 +199,7 @@ teardown() {
echo "status: $status"
assert_success
run /bin/bash -c "dokku domains:clear $TEST_APP"
run /bin/bash -c "dokku domains:reset $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
@@ -347,8 +347,8 @@ teardown() {
echo "status: $status"
assert_success
# run domains:clear in order to invoke default vhost creation
run /bin/bash -c "dokku --quiet domains:clear test.dokku.test"
# run domains:reset in order to invoke default vhost creation
run /bin/bash -c "dokku --quiet domains:reset test.dokku.test"
echo "output: $output"
echo "status: $status"
assert_success