From d05925f6f104f97b20d2c290632a5e716310c947 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 18 Nov 2025 02:35:16 -0500 Subject: [PATCH] feat: allow skipping the install trigger when installing a plugin During docker image generation, certain folders either do not exist or are symlinked in an odd fashion, causing the install trigger to fail. This is not the case at runtime, so we should defer the install trigger until container start and provide a method of skipping it when generating a docker image. Closes #7308 --- docker/etc/my_init.d/10_dokku_init | 2 +- docs/advanced-usage/plugin-management.md | 8 +++++++- docs/getting-started/install/docker.md | 4 ++-- plugins/plugin/functions | 7 +++++++ plugins/plugin/help-functions | 2 +- plugins/plugin/subcommands/install | 1 - 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docker/etc/my_init.d/10_dokku_init b/docker/etc/my_init.d/10_dokku_init index 6307ddefa..38948d4af 100755 --- a/docker/etc/my_init.d/10_dokku_init +++ b/docker/etc/my_init.d/10_dokku_init @@ -86,7 +86,7 @@ main() { fi # run core install triggers to force create any folders that may be missing - dokku plugin:install --core + dokku plugin:install if [[ -n "$DOKKU_HOSTNAME" ]]; then echo "dokku dokku/hostname string $DOKKU_HOSTNAME" | debconf-set-selections diff --git a/docs/advanced-usage/plugin-management.md b/docs/advanced-usage/plugin-management.md index 475a561a0..9da9d35fb 100644 --- a/docs/advanced-usage/plugin-management.md +++ b/docs/advanced-usage/plugin-management.md @@ -6,7 +6,7 @@ ``` plugin:disable # Disable an installed plugin (third-party only) plugin:enable # Enable a previously disabled plugin -plugin:install [--core|git-url] [--committish branch|commit|tag] [--name custom-plugin-name] # Optionally download git-url (and pin to the specified branch/commit/tag) & run install trigger for active plugins (or only core ones) +plugin:install [--core|git-url] [--committish branch|commit|tag] [--name custom-plugin-name] [--skip-install-trigger] # Optionally download git-url (and pin to the specified branch/commit/tag) & run install trigger for active plugins (or only core ones) plugin:installed # Checks if a plugin is installed plugin:install-dependencies [--core] # Run install-dependencies trigger for active plugins (or only core ones) plugin:list # Print active plugins @@ -128,6 +128,12 @@ The `--core` flag may also be indicated as the sole argument, though it is only dokku plugin:install --core ``` +If installing plugins in a Dockerfile, you will want to skip the `install` trigger. This will be run on container boot. + +```shell +dokku plugin:install https://github.com/dokku/smoke-test-plugin.git --name smoke-test-plugin --skip-install-trigger +``` + Finally, all flags may be omitted to trigger the `install` procedures for both core and third-party plugins: ```shell diff --git a/docs/getting-started/install/docker.md b/docs/getting-started/install/docker.md index 47dc1bf98..53c4f9dd7 100644 --- a/docs/getting-started/install/docker.md +++ b/docs/getting-started/install/docker.md @@ -84,8 +84,8 @@ The alternative is to build a custom docker image via a custom Dockerfile. This ```Dockerfile FROM dokku/dokku:0.36.11 -RUN dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres -RUN dokku plugin:install https://github.com/dokku/dokku-redis.git redis +RUN dokku plugin:install https://github.com/dokku/dokku-postgres.git --skip-install-trigger +RUN dokku plugin:install https://github.com/dokku/dokku-redis.git --skip-install-trigger ``` ## SSH Key Management diff --git a/plugins/plugin/functions b/plugins/plugin/functions index dd237aca5..fc5290c80 100755 --- a/plugins/plugin/functions +++ b/plugins/plugin/functions @@ -33,6 +33,7 @@ download_and_enable_plugin() { declare desc="wrapper to download and enable specified version of plugin" local PLUGIN_GIT_URL="$1" shift + local SKIP_INSTALL_TRIGGER=false while getopts ":-:" opt "$@"; do case "$opt" in -) @@ -47,6 +48,9 @@ download_and_enable_plugin() { OPTIND=$((OPTIND + 1)) local CUSTOM_NAME="$val" ;; + skip-install-trigger) + SKIP_INSTALL_TRIGGER=true + ;; esac ;; esac @@ -58,6 +62,9 @@ download_and_enable_plugin() { if [[ -n "$PLUGIN_COMMITTISH" ]]; then update_plugin "$PLUGIN_NAME" "$PLUGIN_COMMITTISH" fi + if [[ "$SKIP_INSTALL_TRIGGER" == "false" ]]; then + plugn trigger install + fi } update_plugin() { diff --git a/plugins/plugin/help-functions b/plugins/plugin/help-functions index 29087e0e7..408de0c62 100755 --- a/plugins/plugin/help-functions +++ b/plugins/plugin/help-functions @@ -29,7 +29,7 @@ fn-help-content() { cat <, Disable an installed plugin (third-party only) plugin:enable , Enable a previously disabled plugin - plugin:install [--core|--git-url] [--committish branch|commit|commit] [--name custom-plugin-name], Optionally download git-url (and pin to the specified branch/commit/tag) & run install trigger for active plugins (or only core ones) + plugin:install [--core|--git-url] [--committish branch|commit|commit] [--name custom-plugin-name] [--skip-install-trigger], Optionally download git-url (and pin to the specified branch/commit/tag) & run install trigger for active plugins (or only core ones) plugin:install-dependencies [--core], Run install-dependencies trigger for active plugins (or only core ones) plugin:list, Print active plugins plugin:trigger , Trigger an arbitrary plugin hook diff --git a/plugins/plugin/subcommands/install b/plugins/plugin/subcommands/install index ab3db3354..2f746f641 100755 --- a/plugins/plugin/subcommands/install +++ b/plugins/plugin/subcommands/install @@ -18,7 +18,6 @@ cmd-plugin-install() { ;; https:* | git* | ssh:* | file:* | *.tar.gz | *.tgz) download_and_enable_plugin "$@" - plugn trigger install ;; *) if [[ -n "$FLAG" ]]; then