2015-09-08 12:31:13 -07:00
# Plugin triggers
2015-02-18 01:49:25 -05:00
2016-09-03 04:39:12 -04:00
[Plugin triggers ](https://github.com/dokku/plugn ) (formerly [pluginhooks ](https://github.com/progrium/pluginhook )) are a good way to jack into existing Dokku infrastructure. You can use them to modify the output of various Dokku commands or override internal configuration.
2015-02-18 01:49:25 -05:00
2015-09-08 12:31:13 -07:00
Plugin triggers are simply scripts that are executed by the system. You can use any language you want, so long as the script:
2015-02-18 01:49:25 -05:00
- Is executable
- Has the proper language requirements installed
2015-09-08 12:31:13 -07:00
For instance, if you wanted to write a plugin trigger in PHP, you would need to have `php` installed and available on the CLI prior to plugin trigger invocation.
2015-02-18 01:49:25 -05:00
2016-09-03 04:39:12 -04:00
The following is an example for the `nginx-hostname` plugin trigger. It reverses the hostname that is provided to nginx during deploys. If you created an executable file named `nginx-hostname` with the following code in your plugin trigger, it would be invoked by Dokku during the normal app deployment process:
2015-02-18 01:49:25 -05:00
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; SUBDOMAIN="$2"; VHOST="$3"
NEW_SUBDOMAIN=`echo $SUBDOMAIN | rev`
echo "$NEW_SUBDOMAIN.$VHOST"
```
2015-09-08 12:31:13 -07:00
## Available plugin triggers
2015-02-18 01:49:25 -05:00
2016-09-03 04:39:12 -04:00
There are a number of plugin-related triggers. These can be optionally implemented by plugins and allow integration into the standard Dokku setup/teardown process.
2015-02-18 01:49:25 -05:00
2016-09-03 04:39:12 -04:00
The following plugin triggers describe those available to a Dokku installation. As well, there is an example for each trigger that you can use as templates for your own plugin development.
2015-02-18 01:49:25 -05:00
2016-12-09 03:46:25 -06:00
> The example plugin trigger code is not guaranteed to be implemented as in within dokku, and are merely simplified examples. Please look at the Dokku source for larger, more in-depth examples.
2015-02-18 01:49:25 -05:00
2020-03-10 18:19:31 -04:00
### `app-create`
- Description: Creates an app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `app-destroy`
- Description: Destroys an app (with confirmation if force isn't specified)
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `app-exists`
- Description: Creates an app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `app-maybe-create`
- Description: Creates an app (gated by whether this is globally enabled or not)
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2019-06-19 13:50:29 -04:00
### `app-restart`
- Description: Triggers an app restart
- Invoked by: `dokku config:clear` , `dokku config:set` , `dokku config:unset`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-04-26 19:21:29 -04:00
### `app-urls`
- Description: Allows you to change the urls Dokku reports for an application. Will override any auto-detected urls.
- Invoked by: `dokku deploy` , `dokku url` , and `dokku urls`
- Arguments: `$APP $URL_TYPE`
- Example:
```shell
#!/usr/bin/env bash
# Sets the domain to `internal.tld`
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; URL_TYPE="$2"
case "$URL_TYPE" in
url)
echo "https://internal.tld/${APP}/"
;;
urls)
echo "https://internal.tld/${APP}/"
echo "http://internal.tld/${APP}/"
;;
esac
```
2019-07-30 14:29:48 -04:00
### `builder-build`
- Description: Triggers the artifact build process
- Invoked by: `dokku deploy`
- Arguments: `$BUILDER_TYPE` `$APP` `$SOURCECODE_WORK_DIR`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-02-04 01:34:12 -05:00
### `builder-detect`
- Description: Allows overriding the auto-detected `herokuish` builder in favor of a custom one. Dockerfile gets lowest builder precedence.
- Invoked by: `dokku deploy`
- Arguments: `$APP` `$SOURCECODE_WORK_DIR`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; SOURCECODE_WORK_DIR="$2"
if [[ -f "$SOURCECODE_WORK_DIR/project.toml" ]]; then
2021-02-28 16:02:22 -05:00
echo -n "pack"
2021-02-04 01:34:12 -05:00
fi
```
2019-07-30 14:58:49 -04:00
### `builder-create-dokku-image`
- Description: Allows modification of the configured dokku-image
- Invoked by: `dokku deploy`
- Arguments: `$BUILDER_TYPE` `$APP` `$SOURCECODE_WORK_DIR` `$DOKKU_IMAGE`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `builder-dokku-image`
- Description: Allows modification of the used dokku-image.
- Invoked by: `dokku deploy`
- Arguments: `$BUILDER_TYPE` `$APP` `$SOURCECODE_WORK_DIR` `$DOKKU_IMAGE`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2019-07-30 14:29:48 -04:00
### `builder-release`
- Description: Triggers the artifact release process
- Invoked by: `dokku deploy`
- Arguments: `$BUILDER_TYPE` `$APP` `$IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `check-deploy`
2015-02-18 01:49:25 -05:00
2016-09-03 04:39:12 -04:00
- Description: Allows you to run checks on a deploy before Dokku allows the container to handle requests.
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku deploy`
2016-08-31 14:21:28 -07:00
- Arguments: `$APP $CONTAINER_ID $PROC_TYPE $PORT $IP`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Disables deploys of containers based on whether the
# `DOKKU_DISABLE_DEPLOY` env var is set to `true` for an app
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
source "$PLUGIN_AVAILABLE_PATH/config/functions"
2015-02-18 01:49:25 -05:00
2019-09-17 02:22:17 -04:00
APP="$1"; CONTAINER_ID="$2"; PROC_TYPE="$3"; PORT="$4" ; IP="$5"
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
eval "$(config_export app $APP)"
DOKKU_DISABLE_DEPLOY="${DOKKU_DISABLE_DEPLOY:-false}"
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
if [[ "$DOKKU_DISABLE_DEPLOY" = "true" ]]; then
echo -e "\033[31m\033[1mDeploys disabled, sorry.\033[0m"
exit 1
fi
2015-02-18 01:49:25 -05:00
```
2018-02-08 18:58:38 +00:00
### `commands help` and `commands <PLUGIN_NAME>:help`
2015-02-18 01:49:25 -05:00
2016-03-15 20:03:35 -07:00
- Description: Your plugin should implement a `help` command in your `commands` file to take advantage of this plugin trigger. `commands help` is used by `dokku help` to aggregate all plugins abbreviated `help` output. Implementing `<PLUGIN_NAME>:help` in your `commands` file gives users looking for help, a more detailed output. 'commands help' must be implemented inside the `commands` plugin file. It's recommended that `PLUGIN_NAME:help` be added to the commands file to ensure consistency among community plugins and give you a new avenue to share rich help content with your user.
- Invoked by: `dokku help` and `commands <PLUGIN_NAME>:help`
2015-02-18 01:49:25 -05:00
- Arguments: None
- Example:
```shell
#!/usr/bin/env bash
2015-09-08 12:31:13 -07:00
# Outputs help for the derp plugin
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
2016-03-15 20:03:35 -07:00
help | hello:help)
help_content_func () {
declare desc="return help_content string"
cat<<help_content
hello <app>, Says "Hello <app>"
hello:world, Says "Hello world"
help_content
}
if [[ $1 = "hello:help" ]] ; then
echo -e 'Usage: dokku hello[:world] [<app>]'
echo ''
echo 'Say Hello World.'
echo ''
echo 'Example:'
echo ''
echo '$ dokku hello:world'
echo 'Hello world'
echo ''
echo 'Additional commands:'
help_content_func | sort | column -c2 -t -s,
else
help_content_func
fi
2015-02-18 01:49:25 -05:00
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac
```
2021-02-11 06:41:11 -05:00
### `config-export`
- Description: Returns the environment variables in a specified format
- Invoked by: app-json plugin
- Arguments: `$APP $GLOBAL $MERGED $FORMAT`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2020-03-10 18:19:04 -04:00
### `config-get`
- Description: Fetches the app config value for a key
- Invoked by:
- Arguments: `$APP $KEY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `config-get-global`
- Description: Fetches the global config value for a key
- Invoked by:
- Arguments: `$KEY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-09-05 00:04:06 -04:00
### `core-post-deploy`
2021-07-09 23:06:38 -04:00
> To avoid issues with community plugins, this plugin trigger should be used _only_ for core plugins. Please avoid using this trigger in your own plugins.
2016-09-05 00:04:06 -04:00
2018-04-07 00:08:30 -04:00
- Description: Allows running of commands after an app's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx.
2016-09-05 00:04:06 -04:00
- Invoked by: `dokku deploy`
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
# Notify an external service that a successful deploy has occurred.
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
curl "http://httpstat.us/200"
```
2021-03-21 21:42:39 -04:00
### `core-post-extract`
2021-07-09 23:21:17 -04:00
> To avoid issues with community plugins, this plugin trigger should be used _only_ for core plugins. Please avoid using this trigger in your own plugins.
2021-03-21 21:42:39 -04:00
2021-07-09 23:21:17 -04:00
- Description: Allows you to modify the contents of an app _ after _ it has been extracted from git/tarball but _ before _ the image source type is detected.
2021-03-21 21:42:39 -04:00
- Invoked by: `dokku tar:in` , `dokku tar:from` and the `receive-app` plugin trigger
- Arguments: `$APP` `$TMP_WORK_DIR` `$REV`
- Example:
```shell
#!/usr/bin/env bash
# Adds a clock process to an app's Procfile
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
TMP_WORK_DIR="$2"
REV="$3" # optional, may not be sent for tar-based builds
pushd "$TMP_WORK_DIR" >/dev/null
touch Procfile
echo "clock: some-command" >> Procfile
popd &>/dev/null
```
2021-02-07 16:17:33 -05:00
### `cron-write`
- Description: Force triggers writing out cron entries
- Invoked by:
- Arguments:
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
# TODO
```
### `cron-entries`
- Description: Allows injecting cron entries into the written out scheduled cron task list. Each entry is newline delimited, and individual entries come in the form `$SCHEDULE;$FULL_COMMAND;$ARBITRARY_DATA` . Individual implementations of cron writing can decide whether and how to include these cron entries. The `ARBITRARY_DATA` includes the log file path for the basic `docker-local` cron implementation.
- Invoked by:
- Arguments: `$DOKKU_SCHEDULER`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
DOKKU_SCHEDULER="$1"
# TODO
```
2016-04-16 14:46:24 -04:00
### `dependencies`
2015-02-18 01:49:25 -05:00
2018-03-03 18:16:50 -05:00
- Description: Used to install system-level dependencies.
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku plugin:install-dependencies`
- Arguments: None
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Installs nginx for the current plugin
# Supports both opensuse and ubuntu
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
export DEBIAN_FRONTEND=noninteractive
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
case "$DOKKU_DISTRO" in
debian|ubuntu)
2021-01-17 16:09:58 -05:00
apt-get -qq -y --no-install-recommends install nginx
2016-04-16 14:46:24 -04:00
;;
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
opensuse)
zypper -q in -y nginx
;;
esac
2015-02-18 01:49:25 -05:00
```
2018-03-03 19:11:49 -05:00
### `deploy-source`
2018-03-03 18:16:50 -05:00
2018-03-03 19:11:49 -05:00
- Description: Used for reporting what the current detected deployment source is. The first detected source should always win.
2018-03-03 18:16:50 -05:00
- Invoked by: `dokku apps:report`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
# Checks if the app should be deployed via git
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
STDIN=$(cat)
2018-03-03 19:11:49 -05:00
# bail if another source is detected
2018-03-03 18:16:50 -05:00
if [[ -n "$STDIN" ]]; then
echo "$STDIN"
return
fi
if [[ -d "$DOKKU_ROOT/$APP/refs" ]]; then
echo "git"
fi
```
2018-03-03 17:57:52 -05:00
### `deployed-app-image-repo`
2016-06-18 01:31:51 -04:00
2018-03-03 17:57:52 -05:00
- Description: Used to manage the full repo of the image being deployed. Useful for deploying from an external registry where the repository name is not `dokku/$APP`
2016-06-18 01:31:51 -04:00
- Invoked by: `internal function dokku_deploy_cmd() (deploy phase)`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2018-03-03 17:57:52 -05:00
APP="$1"
# change the repo from dokku/APP to dokkupaas/APP
echo "dokkupaas/$APP"
2016-06-18 01:31:51 -04:00
```
2018-03-03 17:57:52 -05:00
### `deployed-app-image-tag`
2016-07-05 02:34:13 -04:00
2018-03-03 17:57:52 -05:00
- Description: Used to manage the tag of the image being deployed. Useful for deploying a specific version of an image, or when deploying from an external registry
2016-07-05 02:34:13 -04:00
- Invoked by: `internal function dokku_deploy_cmd() (deploy phase)`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2018-03-03 17:57:52 -05:00
# customize the tag version
echo 'not-latest'
2016-07-05 02:34:13 -04:00
```
2016-06-18 01:31:51 -04:00
### `deployed-app-repository`
- Description: Used to manage the remote repository of the image being deployed.
- Invoked by: `internal function dokku_deploy_cmd() (deploy phase)`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
echo 'derp.dkr.ecr.us-east-1.amazonaws.com'
```
2016-04-16 14:46:24 -04:00
### `docker-args-build`
2015-02-18 01:49:25 -05:00
2019-03-18 18:21:44 -04:00
> Warning: Deprecated, please use `docker-args-process-build` instead
2016-04-16 14:46:24 -04:00
- Description:
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_build() (build phase)`
2016-04-16 14:46:24 -04:00
- Arguments: `$APP $IMAGE_SOURCE_TYPE`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-07-05 02:16:37 -04:00
# Sets a docker build-arg called CACHEBUST which can be used
# to bust cache at any arbitrary point in a Dockerfile build
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2018-03-03 17:57:52 -05:00
STDIN=$(cat)
APP="$1"; IMAGE_SOURCE_TYPE="$2"
output=""
2016-07-05 02:16:37 -04:00
2018-03-03 17:57:52 -05:00
if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]]; then
output=" --build-arg CACHEBUST=$(date +%s)"
fi
echo -n "$STDIN$output"
2015-02-18 01:49:25 -05:00
```
2016-04-16 14:46:24 -04:00
### `docker-args-deploy`
2015-02-18 01:49:25 -05:00
2019-03-18 18:21:44 -04:00
> Warning: Deprecated, please use `docker-args-process-deploy` instead
2016-04-16 14:46:24 -04:00
- Description:
- Invoked by: `dokku deploy`
2017-07-26 08:52:11 -07:00
- Arguments: `$APP $IMAGE_TAG [$PROC_TYPE $CONTAINER_INDEX]`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-02-18 01:49:25 -05:00
# TODO
```
2019-06-19 13:50:29 -04:00
### `docker-args-process-build`
2019-03-18 18:21:44 -04:00
2019-06-19 13:50:29 -04:00
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker deploy options.
- Invoked by: `dokku ps:rebuild`
2020-02-01 16:17:59 -08:00
- Arguments: `$APP $IMAGE_SOURCE_TYPE`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-09-14 22:42:40 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-02-01 16:17:59 -08:00
APP="$1"; IMAGE_SOURCE_TYPE="$2"
2019-03-18 18:21:44 -04:00
# TODO
```
2019-06-19 13:50:29 -04:00
### `docker-args-process-deploy`
2019-05-17 12:00:05 -04:00
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker deploy options.
2019-06-19 13:50:29 -04:00
- Invoked by: `dokku deploy`
2020-02-01 16:17:59 -08:00
- Arguments: `$APP $IMAGE_SOURCE_TYPE $IMAGE_TAG [$PROC_TYPE $CONTAINER_INDEX]`
2019-05-17 12:00:05 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-02-01 16:17:59 -08:00
APP="$1"; $IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3"; PROC_TYPE="$4"; CONTAINER_INDEX="$5"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2019-05-17 12:00:05 -04:00
# TODO
```
2019-06-19 13:50:29 -04:00
### `docker-args-process-run`
2019-03-18 18:21:44 -04:00
2019-06-19 13:50:29 -04:00
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker run options.
- Invoked by: `dokku run`
2020-02-01 16:17:59 -08:00
- Arguments: `$APP $IMAGE_SOURCE_TYPE $IMAGE_TAG`
2019-03-18 18:21:44 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-02-01 16:17:59 -08:00
APP="$1"; IMAGE_SOURCE_TYPE="$3"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2019-03-18 18:21:44 -04:00
# TODO
```
2019-06-19 13:50:29 -04:00
### `docker-args-run`
2019-03-18 18:21:44 -04:00
2019-06-19 13:50:29 -04:00
> Warning: Deprecated, please use `docker-args-process-run` instead
- Description:
2019-03-18 18:21:44 -04:00
- Invoked by: `dokku run`
2019-06-19 13:50:29 -04:00
- Arguments: `$APP $IMAGE_TAG`
2019-03-18 18:21:44 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2020-04-18 18:21:46 -04:00
# TODO
```
2020-05-06 00:16:51 -04:00
### `domains-add`
- Description: Adds a domain to an app
- Invoked by:
- Arguments: `$APP` `$DOMAIN`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `domains-disable`
- Description: Disables domains for an app
- Invoked by:
- Arguments: `$APP` `$RESTART_APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `domains-enable`
- Description: Enables domains for an app
- Invoked by:
- Arguments: `$APP` `$RESTART_APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `domains-list`
- Description: Lists all domains for an app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `domains-setup`
- Description: Initializes domains for an app if enabled
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `domains-vhost-enabled`
- Description: Checks if a virtual hosts are enabled for an app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2020-04-18 18:21:46 -04:00
### `git-deploy-branch`
- Description: Outputs the deploy branch for an app, inherited or not
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
# TODO
2015-02-18 01:49:25 -05:00
```
2021-03-25 20:37:37 -04:00
### `git-from-directory`
- Description: Updates an app's git repository from a source directory and then triggers a build
- Invoked by: `git:from-image` and `git:from-archive`
- Arguments: `$APP $SOURCECODE_WORK_DIR $USER_NAME $USER_EMAIL`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `git-post-pull`
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
- Description:
- Invoked by: `dokku git-upload-pack`
- Arguments: `$APP`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
# TODO
2015-02-18 01:49:25 -05:00
```
2016-04-16 14:46:24 -04:00
### `git-pre-pull`
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
- Description:
- Invoked by: `dokku git-upload-pack`
- Arguments: `$APP`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-07-09 23:06:38 -04:00
> Warning: The `git-pre-pull` trigger should _not_ be used for authentication since it does not get called for commands that use `git-upload-archive` such as `git archive`. Instead, use the [`user-auth`](#user-auth) trigger.
2017-04-03 14:53:47 -04:00
2019-04-17 03:41:16 -04:00
### `git-revision`
- Description: Allows you to fetch the current git revision for a given application
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `install`
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
- Description: Used to setup any files/configuration for a plugin.
- Invoked by: `dokku plugin:install` .
- Arguments: None
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-09-03 04:39:12 -04:00
# Sets the hostname of the Dokku server
2016-04-16 14:46:24 -04:00
# based on the output of `hostname -f`
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2021-08-06 17:48:39 -04:00
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
hostname -f > $DOKKU_ROOT/VHOST
2016-04-16 14:46:24 -04:00
fi
2015-02-18 01:49:25 -05:00
```
2021-01-23 13:39:29 -05:00
### `logs-get-property`
- Description: Fetches a given logs property value
- Invoked by:
- Arguments: `$APP` `$PROPERTY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PROPERTY="$2"
# TODO
```
2017-04-21 02:19:25 -06:00
### `network-build-config`
- Description: Rebuilds network configuration
- Invoked by: `internally triggered by proxy-build-config within proxy implementations`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-07-26 09:53:56 -04:00
### `network-clear-config`
- Description: Clears network configuration
2020-02-17 06:11:52 -05:00
- Invoked by: `internally triggered within proxy implementations`
2018-07-26 09:53:56 -04:00
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-04-21 02:19:25 -06:00
### `network-compute-ports`
- Description: Computes the ports for a given app container
- Invoked by: `internally triggered by proxy-build-config within proxy implementations`
2020-09-08 09:26:35 -04:00
- Arguments: `$APP $PROC_TYPE $IS_HEROKUISH_CONTAINER $CONTAINER_INDEX`
2017-04-21 02:19:25 -06:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-09-03 03:07:24 -04:00
### `network-config-exists`
- Description: Returns whether the network configuration for a given app exists
- Invoked by: `internally triggered by core-post-deploy within proxy implementations`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-04-21 02:19:25 -06:00
### `network-get-ipaddr`
- Description: Return the ipaddr for a given app container
- Invoked by: `internally triggered by a deploy`
- Arguments: `$APP $PROC_TYPE $CONTAINER_ID`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-04-21 02:58:33 -06:00
### `network-get-listeners`
- Description: Return the listeners (host:port combinations) for a given app container
- Invoked by: `internally triggered by a deploy`
2020-03-11 12:34:29 -04:00
- Arguments: `$APP $PROCESS_TYPE`
2017-04-21 02:58:33 -06:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-03-03 17:57:52 -05:00
### `network-get-port`
2017-09-03 20:36:09 -04:00
2018-03-03 17:57:52 -05:00
- Description: Return the port for a given app container
2017-09-03 20:36:09 -04:00
- Invoked by: `internally triggered by a deploy`
2018-03-03 17:57:52 -05:00
- Arguments: `$APP $PROC_TYPE $CONTAINER_ID $IS_HEROKUISH_CONTAINER`
2017-09-03 20:36:09 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-03-03 17:57:52 -05:00
### `network-get-property`
2017-04-21 02:19:25 -06:00
2018-04-07 00:08:30 -04:00
- Description: Return the network value for an app's property
2017-04-21 02:19:25 -06:00
- Invoked by: `internally triggered by a deploy`
2018-03-03 17:57:52 -05:00
- Arguments: `$APP $KEY`
2017-04-21 02:19:25 -06:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-08-06 01:29:25 -04:00
### `network-get-static-listeners`
- Description: Return the network value for an app's property
- Invoked by: `internally triggered by proxy-build-config`
- Arguments: `$APP $PROCESS_TYPE`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-04-21 02:58:33 -06:00
### `network-write-ipaddr`
- Description: Write the ipaddr for a given app index
- Invoked by: `internally triggered by a deploy`
- Arguments: `$APP $PROC_TYPE $CONTAINER_INDEX $IP_ADDRESS`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `network-write-port`
- Description: Write the port for a given app index
- Invoked by: `internally triggered by a deploy`
- Arguments: `$APP $PROC_TYPE $CONTAINER_INDEX $PORT`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2020-05-06 01:38:43 -04:00
# TODO
```
2020-09-06 13:57:35 -04:00
### `nginx-app-template-source`
- Description: Return the path to a `sigil` template that should be used to generate a given nginx configuration file.
- Invoked by: `nginx-vhosts#build-config`
- Arguments: `$APP $TEMPLATE_TYPE`
- The `TEMPLATE_TYPE` argument can be one of: `[app-config, hsts-config, validate-config]`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
TEMPLATE_TYPE="$2"
case "$TEMPLATE_TYPE" in
app-config)
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/app.conf.sigil";;
hsts-config)
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hsts.conf.sigil";;
validate-config)
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/validate.conf.sigil";;
*)
dokku_log_fail "Invalid template type: ${TEMPLATE_TYPE}"
esac
```
The default templates are viewable here: [plugins/nginx-vhosts/templates/ ](https://github.com/dokku/dokku/tree/master/plugins/nginx-vhosts/templates )
2020-05-06 01:38:43 -04:00
### `nginx-dokku-template-source`
2020-07-18 13:25:35 -07:00
- Description: Return the path to a `sigil` template that should be used to generate the `dokku.conf` nginx configuration file.
2020-05-06 01:38:43 -04:00
- Invoked by: `nginx-vhosts#install`
2020-07-18 13:25:35 -07:00
- Arguments: None, however the `sigil` template can make use of the following variables: `$.DOKKU_ROOT $.NGINX_ROOT`
2020-05-06 01:38:43 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2017-04-21 02:58:33 -06:00
2020-07-18 13:25:35 -07:00
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku.conf.sigil"
2017-04-21 02:58:33 -06:00
```
2020-07-18 13:25:35 -07:00
The default template is viewable here: [plugins/nginx-vhosts/templates/dokku.conf.sigil ](https://github.com/dokku/dokku/blob/master/plugins/nginx-vhosts/templates/dokku.conf.sigil )
2016-04-16 14:46:24 -04:00
### `nginx-hostname`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to customize the hostname for a given app
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku domains:setup`
- Arguments: `$APP $SUBDOMAIN $VHOST`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2018-04-07 00:08:30 -04:00
# Reverses the hostname for the app
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
APP="$1"; SUBDOMAIN="$2"; VHOST="$3"
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
NEW_SUBDOMAIN=`echo $SUBDOMAIN | rev`
echo "$NEW_SUBDOMAIN.$VHOST"
2015-02-18 01:49:25 -05:00
```
2016-04-16 14:46:24 -04:00
### `nginx-pre-reload`
2015-02-18 01:49:25 -05:00
2019-05-11 20:47:32 -04:00
> Warning: The arguments INTERNAL_PORT and INTERNAL_IP_ADDRESS are no longer sufficient to retrieve all app listeners. Please run `plugn trigger network-get-listeners APP` within any implementation of `nginx-pre-reload` in order to retrieve all application listeners.
2016-04-16 14:46:24 -04:00
- Description: Run before nginx reloads hosts
- Invoked by: `dokku nginx:build-config`
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Runs a check against all nginx conf files
# to ensure they are valid
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
nginx -t
2015-02-18 01:49:25 -05:00
```
2018-03-03 17:58:04 -05:00
### `post-app-clone`
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after an app was cloned.
2018-03-03 17:58:04 -05:00
- Invoked by: `dokku apps:clone`
- Arguments: `$OLD_APP_NAME $NEW_APP_NAME`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-12-27 04:58:43 -05:00
### `post-app-clone-setup`
- Description: Allows you to run commands after an app is setup, and before it is rebuild. This is useful for cleaning up tasks, or ensuring configuration from an old app is copied to the new app
- Invoked by: `dokku apps:clone`
- Arguments: `$OLD_APP_NAME $NEW_APP_NAME`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-03-03 17:58:04 -05:00
### `post-app-rename`
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after an app was renamed.
2018-03-03 17:58:04 -05:00
- Invoked by: `dokku apps:rename`
- Arguments: `$OLD_APP_NAME $NEW_APP_NAME`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2020-02-18 01:13:29 -05:00
### `post-app-rename-setup`
- Description: Allows you to run commands after an app is setup, and before it is rebuild. This is useful for cleaning up tasks, or ensuring configuration from an old app is copied to the new app
- Invoked by: `dokku apps:rename`
- Arguments: `$OLD_APP_NAME $NEW_APP_NAME`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-build-buildpack`
2015-11-25 19:11:32 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after the build image is create for a given app. Only applies to apps using buildpacks.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_build() (build phase)`
2019-08-12 16:08:31 -04:00
- Arguments: `$APP` `$SOURCECODE_WORK_DIR`
2015-11-25 19:11:32 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
# TODO
2015-11-25 19:11:32 -05:00
```
2021-02-28 16:02:22 -05:00
### `post-build-pack`
2020-12-01 14:49:39 -05:00
2021-02-28 16:02:22 -05:00
> Warning: The pack plugin trigger apis are under development and may change
2020-12-01 14:49:39 -05:00
> between minor releases until the 1.0 release.
2021-02-28 16:02:22 -05:00
- Description: Allows you to run commands after the build image is create for a given app. Only applies to apps using pack.
2020-12-01 14:49:39 -05:00
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP` `$SOURCECODE_WORK_DIR`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-build-dockerfile`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after the build image is create for a given app. Only applies to apps using a dockerfile.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_build() (build phase)`
2016-04-16 14:46:24 -04:00
- Arguments: `$APP`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
# TODO
2015-02-18 01:49:25 -05:00
```
2017-04-21 02:19:25 -06:00
### `post-certs-remove`
- Description: Allows you to run commands after a cert is removed
- Invoked by: `dokku certs:remove`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2017-04-21 02:19:25 -06:00
# TODO
```
### `post-certs-update`
- Description: Allows you to run commands after a cert is added/updated
- Invoked by: `dokku certs:add` , `dokku certs:update`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2017-04-21 02:19:25 -06:00
# TODO
```
2018-03-03 17:57:52 -05:00
### `post-config-update`
2021-07-09 23:06:38 -04:00
- Description: Allows you to get notified when one or more configs is added or removed. Action can be `set` or `unset` .
2018-03-03 17:57:52 -05:00
- Invoked by: `dokku config:set` , `dokku config:unset`
- Arguments: `$APP` `set|unset` `key1=VALUE1 key2=VALUE2`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2020-02-03 04:37:31 -05:00
### `post-container-create`
- Description: This trigger should be used to do stuff to containers after they are created but before they are started. They are explicitely for commands that may involve network traffic, and _ not _ for commands that are self-contained, such as chown or tar.
- Invoked by: `dokku run` , `dokku ps:rebuild` , `dokku deploy`
- Arguments "app|service" "$CONTAINER_ID" "$APP|$SERVICE" "$PHASE"
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-create`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Can be used to run commands after an app is created.
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku apps:create`
- Arguments: `$APP`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Runs a command to ensure that an app
# has a postgres database when it is starting
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
APP="$1";
POSTGRES="$1"
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
dokku postgres:create $POSTGRES
dokku postgres:link $POSTGRES $APP
2015-02-18 01:49:25 -05:00
```
### `post-delete`
2018-04-07 00:08:30 -04:00
- Description: Can be used to run commands after an app is deleted.
2015-02-18 01:49:25 -05:00
- Invoked by: `dokku apps:destroy`
2015-09-03 16:07:23 -07:00
- Arguments: `$APP $IMAGE_TAG`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
# Runs a command to ensure that an app's
# postgres installation is removed
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
dokku postgres:destroy $APP
```
2016-04-16 14:46:24 -04:00
### `post-deploy`
2015-10-26 13:33:04 +01:00
2016-09-05 00:04:06 -04:00
> Please see [core-post-deploy](#core-post-deploy) if contributing a core plugin with the `post-deploy` hook.
2018-04-07 00:08:30 -04:00
- Description: Allows running of commands after an app's processes have been scaled up, but before old containers are torn down. Dokku calls this _ after _ `core-post-deploy` . Deployment Tasks are also invoked by this plugin trigger.
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku deploy`
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
2015-10-26 13:33:04 +01:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Notify an external service that a successful deploy has occurred.
2015-10-26 13:33:04 +01:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
curl "http://httpstat.us/200"
2015-10-26 13:33:04 +01:00
```
2016-04-16 14:46:24 -04:00
### `post-domains-update`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- 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
2016-11-28 21:55:59 +07:00
- Invoked by: `dokku domains:add` , `dokku domains:clear` , `dokku domains:remove` , `dokku domains:set`
2016-04-16 14:46:24 -04:00
- Arguments: `$APP` `action name` `domains`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Reloads haproxy for our imaginary haproxy plugin
# that replaces the nginx-vhosts plugin
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
sudo service haproxy reload
2015-02-18 01:49:25 -05:00
```
2017-03-16 04:25:18 -06:00
### `post-extract`
2021-07-09 23:06:38 -04:00
- Description: Allows you to modify the contents of an app _ after _ it has been extracted from git/tarball but _ before _ the image source type is detected.
2017-03-16 04:25:18 -06:00
- Invoked by: `dokku tar:in` , `dokku tar:from` and the `receive-app` plugin trigger
- Arguments: `$APP` `$TMP_WORK_DIR` `$REV`
- Example:
```shell
#!/usr/bin/env bash
# Adds a clock process to an app's Procfile
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2017-03-16 04:25:18 -06:00
TMP_WORK_DIR="$2"
REV="$3" # optional, may not be sent for tar-based builds
2019-02-02 13:49:24 -05:00
pushd "$TMP_WORK_DIR" >/dev/null
2017-03-16 04:25:18 -06:00
touch Procfile
echo "clock: some-command" >> Procfile
2021-03-01 00:30:34 -05:00
popd &>/dev/null
2017-03-16 04:25:18 -06:00
```
2016-06-15 18:05:10 -07:00
### `post-proxy-ports-update`
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands once the proxy port mappings for an app have been updated. It also sends the invoking command. This can be "add", "clear" or "remove".
2016-06-15 18:05:10 -07:00
- Invoked by: `dokku proxy:ports-add` , `dokku proxy:ports-clear` , `dokku proxy:ports-remove`
- Arguments: `$APP` `action name`
- Example:
```shell
#!/usr/bin/env bash
# Rebuilds haproxy config for our imaginary haproxy plugin
# that replaces the nginx-vhosts plugin
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/haproxy/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2016-06-15 18:05:10 -07:00
haproxy-build-config "$APP"
```
2021-08-03 16:23:33 -04:00
### `post-release-builder`
> Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
- Description: Invokes a command after the build process is complete.
- Invoked by: builder plugins
- Arguments: `$BUILDER_TYPE $APP $IMAGE`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
BUILDER_TYPE="$1"; APP="$2"; IMAGE=$3
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-release-buildpack`
2015-02-18 01:49:25 -05:00
2021-08-05 20:14:30 -04:00
> Warning: Deprecated, please use `post-release-builder` instead
2020-02-18 01:32:41 -05:00
> Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after environment variables are set for the release step of the deploy. Only applies to apps using buildpacks.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_release() (release phase)`
2015-09-03 16:07:23 -07:00
- Arguments: `$APP $IMAGE_TAG`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-09-14 22:42:40 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2015-09-03 16:43:44 -07:00
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-02-18 01:49:25 -05:00
2020-02-18 01:32:41 -05:00
# TODO
2015-02-18 01:49:25 -05:00
```
2021-02-28 16:02:22 -05:00
### `post-release-pack`
2020-12-01 14:49:39 -05:00
2021-08-05 20:14:30 -04:00
> Warning: Deprecated, please use `post-release-builder` instead
2021-08-03 16:23:33 -04:00
2021-02-28 16:02:22 -05:00
> Warning: The pack plugin trigger apis are under development and may change
2020-12-01 14:49:39 -05:00
> between minor releases until the 1.0 release.
> Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
2021-02-28 16:02:22 -05:00
- Description: Allows you to run commands after environment variables are set for the release step of the deploy. Only applies to apps using pack.
2020-12-01 14:49:39 -05:00
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-release-dockerfile`
2015-02-18 01:49:25 -05:00
2021-08-05 20:14:30 -04:00
> Warning: Deprecated, please use `post-release-builder` instead
2021-08-03 16:23:33 -04:00
2020-02-18 01:32:41 -05:00
> Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands after environment variables are set for the release step of the deploy. Only applies to apps using a dockerfile.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_release() (release phase)`
2015-09-03 16:07:23 -07:00
- Arguments: `$APP $IMAGE_TAG`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-09-14 22:42:40 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2015-09-03 16:43:44 -07:00
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-02-18 01:49:25 -05:00
# TODO
```
2016-04-16 14:46:24 -04:00
### `post-stop`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Can be used to run commands after an app is manually stopped
2020-11-21 17:31:25 -05:00
- Invoked by: `dokku ps:stop`
2015-02-18 01:49:25 -05:00
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
2018-04-07 00:08:30 -04:00
# Marks an app as manually stopped
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
APP="$1";
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
dokku config:set --no-restart $APP MANUALLY_STOPPED=1
2015-02-18 01:49:25 -05:00
```
2016-04-16 14:46:24 -04:00
### `pre-build-buildpack`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands before the build image is created for a given app. For instance, this can be useful to add env vars to your container. Only applies to apps using buildpacks.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_build() (build phase)`
2019-08-12 16:08:31 -04:00
- Arguments: `$APP` `$SOURCECODE_WORK_DIR`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-02-28 16:02:22 -05:00
### `pre-build-pack`
2020-12-01 14:49:39 -05:00
2021-02-28 16:02:22 -05:00
> Warning: The pack plugin trigger apis are under development and may change
2020-12-01 14:49:39 -05:00
> between minor releases until the 1.0 release.
2021-02-28 16:02:22 -05:00
- Description: Allows you to run commands before the build image is created for a given app. For instance, this can be useful to add env vars to your container. Only applies to apps using pack.
2020-12-01 14:49:39 -05:00
- Invoked by: `internal function dokku_build() (build phase)`
- Arguments: `$APP` `$SOURCECODE_WORK_DIR`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `pre-build-dockerfile`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands before the build image is created for a given app. For instance, this can be useful to add env vars to your container. Only applies to apps using a dockerfile.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_build() (build phase)`
2015-02-18 01:49:25 -05:00
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2016-04-16 14:46:24 -04:00
### `pre-delete`
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
- Description: Can be used to run commands before an app is deleted.
- Invoked by: `dokku apps:destroy`
- Arguments: `$APP $IMAGE_TAG`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2018-04-07 00:08:30 -04:00
# Clears out the gulp asset build cache for apps
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
APP="$1"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
if [[ -d $GULP_CACHE_DIR ]]; then
2019-07-19 15:50:55 -04:00
docker run "${DOCKER_COMMIT_LABEL_ARGS[@]}" --rm -v "$GULP_CACHE_DIR:/gulp" "$IMAGE" find /gulp -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true
2016-04-16 14:46:24 -04:00
fi
2015-02-18 01:49:25 -05:00
```
2016-04-16 14:46:24 -04:00
### `pre-deploy`
2015-02-18 01:49:25 -05:00
2018-04-07 00:08:30 -04:00
- Description: Allows the running of code before the app's processes are scaled up and after the docker images are prepared.
2016-04-16 14:46:24 -04:00
- Invoked by: `dokku deploy`
- Arguments: `$APP $IMAGE_TAG`
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Runs gulp in our container
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-02-18 01:49:25 -05:00
2016-04-16 14:46:24 -04:00
dokku_log_info1 "Running gulp"
2019-07-19 15:50:55 -04:00
CID=$(docker run "${DOCKER_COMMIT_LABEL_ARGS[@]}" -d $IMAGE /bin/bash -c "cd /app && gulp default")
test $(docker wait $CID) -eq 0
DOCKER_COMMIT_LABEL_ARGS=("--change" "LABEL org.label-schema.schema-version=1.0" "--change" "LABEL org.label-schema.vendor=dokku" "--change" "LABEL com.dokku.app-name=$APP")
docker commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" $CID $IMAGE >/dev/null
2015-02-18 01:49:25 -05:00
```
2018-03-03 17:57:52 -05:00
### `pre-disable-vhost`
- Description: Allows you to run commands before the VHOST feature is disabled
- Invoked by: `dokku domains:disable`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2018-03-03 17:57:52 -05:00
# TODO
```
### `pre-enable-vhost`
- Description: Allows you to run commands before the VHOST feature is enabled
- Invoked by: `dokku domains:enable`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
2020-12-25 00:13:41 -05:00
APP="$1"
2018-03-03 17:57:52 -05:00
# TODO
```
2015-10-24 00:20:54 -04:00
### `pre-receive-app`
2018-04-07 00:08:30 -04:00
- Description: Allows you to customize the contents of an app directory before they are processed for deployment. The `IMAGE_SOURCE_TYPE` can be any of `[herokuish, dockerfile]`
2015-10-24 00:20:54 -04:00
- Invoked by: `dokku git-hook` , `dokku tar-build-locked`
2015-11-05 18:46:18 -08:00
- Arguments: `$APP $IMAGE_SOURCE_TYPE $TMP_WORK_DIR $REV`
2015-10-24 00:20:54 -04:00
- Example:
```shell
#!/usr/bin/env bash
# Adds a file called `dokku-is-awesome` to the repository
2018-04-07 00:08:30 -04:00
# the contents will be the app name
2015-10-24 00:20:54 -04:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-11-05 18:46:18 -08:00
APP="$1"; IMAGE_SOURCE_TYPE="$2"; TMP_WORK_DIR="$3"; REV="$4"
2015-10-24 00:20:54 -04:00
echo "$APP" > "$TMP_WORK_DIR/dokku-is-awesome"
```
2016-04-16 14:46:24 -04:00
### `pre-release-buildpack`
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands before environment variables are set for the release step of the deploy. Only applies to apps using buildpacks.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_release() (release phase)`
2016-04-16 14:46:24 -04:00
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
# Installs the graphicsmagick package into the container
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2016-08-04 16:17:28 +01:00
dokku_log_info1 "Installing GraphicsMagick..."
2016-04-16 14:46:24 -04:00
CMD="cat > gm && \
2019-02-02 13:49:24 -05:00
dpkg -s graphicsmagick >/dev/null 2>&1 || \
2021-01-17 16:09:58 -05:00
(apt-get update -qq && apt-get -qq -y --no-install-recommends install graphicsmagick && apt-get clean)"
2016-04-16 14:46:24 -04:00
2020-02-18 01:32:41 -05:00
CID=$(docker run $DOKKU_GLOBAL_RUN_ARGS -i -a stdin $IMAGE /bin/bash -c "$CMD")
2019-07-19 15:50:55 -04:00
test $(docker wait $CID) -eq 0
2020-02-18 01:32:41 -05:00
DOCKER_COMMIT_LABEL_ARGS=("--change" "LABEL org.label-schema.schema-version=1.0" "--change" "LABEL org.label-schema.vendor=dokku" "--change" "LABEL com.dokku.app-name=$APP")
2019-07-19 15:50:55 -04:00
docker commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" $CID $IMAGE >/dev/null
2016-04-16 14:46:24 -04:00
```
2021-02-28 16:02:22 -05:00
### `pre-release-pack`
2020-12-01 14:49:39 -05:00
2021-02-28 16:02:22 -05:00
> Warning: The pack plugin trigger apis are under development and may change
2020-12-01 14:49:39 -05:00
> between minor releases until the 1.0 release.
2021-02-28 16:02:22 -05:00
- Description: Allows you to run commands before environment variables are set for the release step of the deploy. Only applies to apps using pack.
2020-12-01 14:49:39 -05:00
- Invoked by: `internal function dokku_release() (release phase)`
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2";
# TODO
```
2016-04-16 14:46:24 -04:00
### `pre-release-dockerfile`
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands before environment variables are set for the release step of the deploy. Only applies to apps using a dockerfile.
2016-06-17 19:30:25 -07:00
- Invoked by: `internal function dokku_release() (release phase)`
2016-04-16 14:46:24 -04:00
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
# TODO
```
2018-04-07 00:05:30 -04:00
### `pre-restore`
- Description: Allows you to run commands before all containers are restored
- Invoked by: `dokku ps:restore`
- Arguments: `$DOKKU_SCHEDULER`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"
# TODO
```
2017-12-19 00:54:20 -05:00
### `pre-start`
2018-04-07 00:08:30 -04:00
- Description: Can be used to run commands before an app is started
2017-12-19 00:54:20 -05:00
- Invoked by: `dokku ps:start`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
2018-04-07 00:08:30 -04:00
# Notifies an example url that an app is starting
2017-12-19 00:54:20 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
2018-04-07 14:19:14 -04:00
curl "https://dokku.me/starting/${APP}" || true
2017-12-19 00:54:20 -05:00
```
2020-08-01 21:56:19 -04:00
### `procfile-extract`
- Description: Extracts a Procfile from a given image to a path
- Invoked by: `internally`
2020-11-01 17:40:26 -05:00
- Arguments: `$APP $IMAGE`
2020-08-01 21:56:19 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `procfile-get-command`
- Description: Fetches the command for a specific process type
- Invoked by: `internally`
2020-11-01 17:30:24 -05:00
- Arguments: `$APP $PROCESS_TYPE $PORT`
2020-08-01 21:56:19 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `procfile-remove`
- Description: Removes the extracted Procfile
- Invoked by: `internally`
2020-11-22 17:12:51 -05:00
- Arguments: `$APP`
2020-08-01 21:56:19 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2017-04-21 02:19:25 -06:00
### `proxy-build-config`
2016-06-15 18:05:10 -07:00
2017-04-21 02:19:25 -06:00
- Description: Builds the proxy implementation configuration for a given app
- Invoked by: `internally triggered by ps:restore`
2016-06-15 18:05:10 -07:00
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2018-07-26 09:53:56 -04:00
### `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
```
2019-06-19 13:50:29 -04:00
### `proxy-disable`
2016-06-15 18:05:10 -07:00
2019-06-19 13:50:29 -04:00
- Description: Disables the configured proxy implementation for an app
2017-04-21 02:19:25 -06:00
- Invoked by: `internally triggered by ps:restore`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2019-06-19 13:50:29 -04:00
### `proxy-enable`
2017-04-21 02:19:25 -06:00
2019-06-19 13:50:29 -04:00
- Description: Enables the configured proxy implementation for an app
2017-04-21 02:19:25 -06:00
- Invoked by: `internally triggered by ps:restore`
2016-06-15 18:05:10 -07:00
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2020-02-22 06:35:30 -05:00
### `proxy-is-enabled`
- Description: Checks if there is a proxy enabled for the app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `proxy-type`
- Description: Returns the proxy type for an app
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-08-01 17:53:25 -04:00
### `ps-can-scale`
- Description: Sets whether or not a user can scale an app with `ps:scale`
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-08-01 01:43:35 -04:00
### `ps-current-scale`
- Description: Prints out the current scale contents (process-type=quantity) delimited by newlines.
- Invoked by:
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2021-08-01 16:11:09 -04:00
### `ps-set-scale`
- Description: Sets the scale for an app based on a specified formation (process-type=quantity). Any unspecified process types will be left as is.
- Invoked by:
2021-08-01 17:53:57 -04:00
- Arguments: `$APP $SKIP_DEPLOY $CLEAR_EXISTING [$PROCESS_TUPLE...]`
2021-08-01 16:11:09 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
2015-02-18 01:49:25 -05:00
### `receive-app`
2018-04-07 00:08:30 -04:00
- Description: Allows you to customize what occurs when an app is received. Normally just triggers an app build.
2015-02-18 01:49:25 -05:00
- Invoked by: `dokku git-hook` , `dokku ps:rebuild`
2016-06-22 14:39:52 -04:00
- Arguments: `$APP $REV` (`$REV` may not be included in cases where a repository is not pushed)
2015-02-18 01:49:25 -05:00
- Example:
```shell
#!/usr/bin/env bash
2015-09-08 12:31:13 -07:00
# For our imaginary mercurial plugin, triggers a rebuild
2015-02-18 01:49:25 -05:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; REV="$2"
dokku hg-build $APP $REV
```
2015-07-03 17:11:53 -04:00
### `receive-branch`
- Description: Allows you to customize what occurs when a specific branch is received. Can be used to add support for specific branch names
- Invoked by: `dokku git-hook` , `dokku ps:rebuild`
- Arguments: `$APP $REV $REFNAME`
- Example:
```shell
#!/bin/bash
2016-09-03 04:39:12 -04:00
# Gives Dokku the ability to support multiple branches for a given service
2015-07-03 17:11:53 -04:00
# Allowing you to have multiple staging environments on a per-branch basis
reference_app=$1
refname=$3
newrev=$2
APP=${refname/*\//}.$reference_app
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
2017-12-18 18:13:35 +00:00
REFERENCE_REPO="$DOKKU_ROOT/$reference_app"
2019-02-02 13:49:24 -05:00
git clone --bare --shared --reference "$REFERENCE_REPO" "$REFERENCE_REPO" "$DOKKU_ROOT/$APP" >/dev/null
2015-07-03 17:11:53 -04:00
fi
2015-09-08 12:31:13 -07:00
plugn trigger receive-app $APP $newrev
2015-07-03 17:11:53 -04:00
```
2015-06-10 18:10:48 -07:00
2020-10-10 17:32:21 -04:00
### `release-and-deploy`
- Description: Triggers a release of the image tag and a subsequent deploy
- Invoked by:
- Arguments: `$APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
# TODO
```
2019-06-19 13:50:29 -04:00
### `report`
- Description: Allows you to report on any custom configuration in use by your application
- Invoked by: `dokku report`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
# TODO
```
2019-04-08 11:30:45 -04:00
### `resource-get-property`
- Description: Fetches a given resource property value
- Invoked by:
- Arguments: `$APP` `$PROC_TYPE` `$RESOURCE_TYPE` `$PROPERTY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PROC_TYPE="$2" RESOURCE_TYPE="$3" PROPERTY="$4"
# TODO
```
2016-04-16 14:46:24 -04:00
### `retire-container-failed`
- Description: Allows you to run commands if/when retiring old containers has failed
- Invoked by: `dokku deploy`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
# Send an email when a container failed to retire
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; HOSTNAME=$(hostname -s)
2018-04-07 14:19:14 -04:00
mail -s "$APP containers on $HOSTNAME failed to retire" ops@dokku .me
2016-04-16 14:46:24 -04:00
```
2019-06-19 13:50:29 -04:00
### `scheduler-app-status`
2018-04-07 04:49:21 -04:00
2019-06-19 13:50:29 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Fetch the status of an app
- Invoked by: `dokku ps:report`
- Arguments: `$DOKKU_SCHEDULER $APP`
2018-04-07 04:49:21 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2019-06-19 13:50:29 -04:00
DOKKU_SCHEDULER="$1"; APP="$2";
2018-04-07 04:49:21 -04:00
# TODO
```
2018-04-06 23:18:00 -04:00
### `scheduler-deploy`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when an app is deployed
- Invoked by: `dokku deploy`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP $IMAGE_TAG`
2018-04-07 00:05:30 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_TAG="$3";
# TODO
```
2018-04-06 23:18:00 -04:00
### `scheduler-docker-cleanup`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when dokku cleanup is invoked
- Invoked by: `dokku deploy, dokku cleanup`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP $FORCE_CLEANUP`
2018-04-07 00:05:30 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; FORCE_CLEANUP="$3";
# TODO
```
2020-05-12 23:06:10 -04:00
### `scheduler-enter`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to enter a running container for a given app
- Invoked by: `dokku enter`
- Arguments: `$DOKKU_SCHEDULER $APP $@`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; ARGS="$@"
# TODO
```
2018-10-14 19:39:24 -04:00
### `scheduler-inspect`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run inspect commands for all containers for a given app
- Invoked by: `dokku ps:inspect`
- Arguments: `$DOKKU_SCHEDULER $APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
```
2019-04-17 03:04:43 -04:00
### `scheduler-logs`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when retrieving container logs
- Invoked by: `dokku logs:failed`
- Arguments: `$DOKKU_SCHEDULER $APP $PROCESS_TYPE $TAIL $PRETTY_PRINT $NUM`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; PROCESS_TYPE="$3"; TAIL="$4"; PRETTY_PRINT="$5"; NUM="$6"
# TODO
```
2018-07-29 19:31:20 -04:00
### `scheduler-logs-failed`
2018-07-29 19:30:45 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when retrieving failed container logs
- Invoked by: `dokku logs:failed`
- Arguments: `$DOKKU_SCHEDULER $APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2019-04-17 03:04:43 -04:00
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
```
2019-06-19 13:50:29 -04:00
### `scheduler-post-delete`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when an app is deleted
- Invoked by: `dokku apps:destroy`
- Arguments: `$DOKKU_SCHEDULER $APP $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_TAG="$3";
# TODO
```
2019-09-17 02:22:17 -04:00
### `scheduler-post-run`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands after a `dokku run` invocation is called
- Invoked by: `dokku run`
- Arguments: `$DOKKU_SCHEDULER $APP $CONTAINER_ID`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; CONTAINER_ID="$3";
# TODO
```
2020-11-22 16:57:39 -05:00
### `scheduler-register-retired`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2020-11-26 03:21:45 -05:00
- Description: Allows scheduling retiring a local container and any related images
2020-11-22 16:57:39 -05:00
- Invoked by: `internally`
- Arguments: `$APP $CONTAINER_ID`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
CONTAINER_ID="$2";
# TODO
```
2019-04-17 03:04:43 -04:00
### `scheduler-retire`
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
- Description: Allows you to run scheduler commands when containers should be force retired from the system
- Invoked by: `dokku run`
- Arguments: `$DOKKU_SCHEDULER`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1";
2018-07-29 19:30:45 -04:00
# TODO
```
2018-04-06 23:18:00 -04:00
### `scheduler-run`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when a command is executed for your app
- Invoked by: `dokku run`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP ...ARGS`
2018-04-07 00:05:30 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; ARGS="${@:3 }";
# TODO
```
2018-04-06 23:18:00 -04:00
### `scheduler-stop`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when a tag is destroyed
- Invoked by: `dokku apps:destroy, dokku ps:stop`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP $REMOVE_CONTAINERS`
2018-04-07 00:05:30 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; REMOVE_CONTAINERS="$3";
# TODO
```
2018-04-06 23:18:00 -04:00
### `scheduler-tags-create`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when a tag is created
- Invoked by: `dokku tags:create`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP $SOURCE_IMAGE $TARGET_IMAGE`
2018-04-07 00:05:30 -04:00
- Example:
2018-04-06 23:18:00 -04:00
2018-04-07 00:05:30 -04:00
```shell
#!/usr/bin/env bash
2018-04-06 23:18:00 -04:00
2018-04-07 00:05:30 -04:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1" APP="$2" SOURCE_IMAGE="$3" TARGET_IMAGE="$4"
# TODO
```
### `scheduler-tags-destroy`
2018-07-29 19:32:53 -04:00
> Warning: The scheduler plugin trigger apis are under development and may change
> between minor releases until the 1.0 release.
2018-04-07 00:05:30 -04:00
- Description: Allows you to run scheduler commands when a tag is destroyed
- Invoked by: `dokku tags:destroy`
2018-07-29 19:32:53 -04:00
- Arguments: `$DOKKU_SCHEDULER $APP $IMAGE_REPO $IMAGE_TAG`
2018-04-06 23:18:00 -04:00
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2018-04-07 00:05:30 -04:00
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_REPO="$3"; IMAGE_TAG="$4";
2018-04-06 23:18:00 -04:00
2018-04-07 00:05:30 -04:00
# TODO
2018-04-06 23:18:00 -04:00
```
2021-01-23 12:32:31 -05:00
### `storage-list`
- Description: Returns a list of storage mounts
- Invoked by: `dokku storage:list` and `dokku deploy`
- Arguments: `$APP`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
# TODO
```
2015-09-03 18:26:02 -07:00
### `tags-create`
2015-06-10 18:10:48 -07:00
2018-04-07 00:05:30 -04:00
- Description: Allows you to run commands once a tag for an app image has been added
2015-09-03 18:26:02 -07:00
- Invoked by: `dokku tags:create`
2015-09-03 16:07:23 -07:00
- Arguments: `$APP $IMAGE_TAG`
2015-06-10 18:10:48 -07:00
- Example:
```shell
#!/usr/bin/env bash
2018-04-07 00:05:30 -04:00
# Upload an app image to docker hub
2015-06-10 18:10:48 -07:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-09-03 16:07:23 -07:00
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
2015-06-10 18:10:48 -07:00
IMAGE_ID=$(docker inspect --format '{{ .Id }}' $IMAGE)
2015-09-03 16:07:23 -07:00
docker tag -f $IMAGE_ID $DOCKER_HUB_USER/$APP:$IMAGE_TAG
docker push $DOCKER_HUB_USER/$APP:$IMAGE_TAG
2015-06-10 18:10:48 -07:00
```
2015-09-03 18:26:02 -07:00
### `tags-destroy`
2015-06-10 18:10:48 -07:00
2018-04-07 00:08:30 -04:00
- Description: Allows you to run commands once a tag for an app image has been removed
2015-09-03 18:26:02 -07:00
- Invoked by: `dokku tags:destroy`
2015-09-03 16:07:23 -07:00
- Arguments: `$APP $IMAGE_TAG`
2015-06-10 18:10:48 -07:00
- Example:
```shell
#!/usr/bin/env bash
# Remove an image tag from docker hub
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2015-09-03 16:07:23 -07:00
APP="$1"; IMAGE_TAG="$2"
2015-06-10 18:10:48 -07:00
2017-12-18 18:13:35 +00:00
# some code to remove a docker hub tag because it's not implemented in the CLI...
2015-06-10 18:10:48 -07:00
```
2015-09-10 08:47:48 -07:00
2016-11-17 12:55:08 -06:00
### `uninstall`
2016-11-20 17:49:02 -06:00
2021-07-09 23:06:38 -04:00
- Description: Used to cleanup after itself.
- Invoked by: `dokku plugin:uninstall`
- Arguments: `$PLUGIN`
- Example:
2016-11-17 12:55:08 -06:00
2017-12-18 18:13:35 +00:00
```shell
#!/usr/bin/env bash
# Cleanup up extra containers created
2016-11-17 12:55:08 -06:00
2017-12-18 18:13:35 +00:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-11-17 12:55:08 -06:00
2017-12-18 18:13:35 +00:00
PLUGIN="$1"
2016-11-17 16:06:57 -06:00
2017-12-18 18:13:35 +00:00
[[ "$PLUGIN" = "my-plugin" ]] && docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}"
```
2016-11-17 12:55:08 -06:00
2016-11-20 17:49:02 -06:00
> To avoid uninstalling other plugins make sure to check the plugin name like shown in the example.
2016-04-16 14:46:24 -04:00
### `update`
2015-09-10 08:47:48 -07:00
2016-04-16 14:46:24 -04:00
- Description: Can be used to run plugin updates on a regular interval. You can schedule the invoker in a cron-task to ensure your system gets regular updates.
- Invoked by: `dokku plugin:update` .
- Arguments: None
2015-09-10 08:47:48 -07:00
- Example:
```shell
#!/usr/bin/env bash
2016-04-16 14:46:24 -04:00
# Update the herokuish image from git source
2015-09-10 08:47:48 -07:00
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
2016-04-16 14:46:24 -04:00
cd /root/dokku
sudo BUILD_STACK=true make install
2015-09-10 08:47:48 -07:00
```
2015-11-08 15:36:04 -05:00
### `user-auth`
2021-07-09 23:06:38 -04:00
This is a special plugin trigger that is executed on _ every _ command run. As Dokku sometimes internally invokes the `dokku` command, special care should be taken to properly handle internal command redirects.
2015-11-08 15:36:04 -05:00
Note that the trigger should exit as follows:
- `0` to continue running as normal
- `1` to halt execution of the command
The `SSH_USER` is the original ssh user. If you are running remote commands, this user will typically be `dokku` , and as such should not be trusted when checking permissions. If you are connected via ssh as a different user who then invokes `dokku` , the value of this variable will be that user's name (`root` , `myuser` , etc.).
2021-08-06 17:48:39 -04:00
The `SSH_NAME` is the `NAME` variable set via the `sshcommand acl-add` command. For reference, the following command can be run as the root user to specify a specific `NAME` for a given ssh key:
2015-11-08 15:36:04 -05:00
```shell
sshcommand acl-add dokku NAME < $PATH_TO_SSH_KEY
```
Note that the `NAME` value is set at the first ssh key match. If an ssh key is set in the `/home/dokku/.ssh/authorized_keys` multiple times, the first match will decide the value.
2016-09-03 04:39:12 -04:00
- Description: Allows you to deny access to a Dokku command by either ssh user or associated ssh-command NAME user.
2018-03-03 18:16:50 -05:00
- Invoked by: `dokku`
2015-11-08 15:36:04 -05:00
- Arguments: `$SSH_USER $SSH_NAME $DOKKU_COMMAND`
- Example:
```shell
#!/usr/bin/env bash
# Allow root/admin users to do everything
# Deny plugin access to default users
# Allow access to all other commands
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
SSH_USER=$1
SSH_NAME=$2
shift 2
[[ "$SSH_USER" == "root" ]] && exit 0
[[ "$SSH_NAME" == "admin" ]] && exit 0
[[ "$SSH_NAME" == "default" && $1 == plugin:* ]] && exit 1
exit 0
```