Plugin triggers (formerly pluginhooks) 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.
Plugin triggers are simply scripts that are executed by the system. You can use any language you want, so long as the script:
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.
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:
#!/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"
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.
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.
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.
app-create
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-destroy
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-exists
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-json-process-deploy-parallelism
dokku deploy
$APP $PROCESS_TYPE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-maybe-create
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-restart
dokku config:clear
, dokku config:set
, dokku config:unset
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
app-urls
dokku deploy
, dokku url
, and dokku urls
$APP $URL_TYPE
#!/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
builder-build
dokku deploy
$BUILDER_TYPE
$APP
$SOURCECODE_WORK_DIR
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
builder-detect
herokuish
builder in favor of a custom one. Dockerfile gets lowest builder precedence.dokku deploy
$APP
$SOURCECODE_WORK_DIR
#!/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
echo -n "pack"
fi
builder-create-dokku-image
dokku deploy
$BUILDER_TYPE
$APP
$SOURCECODE_WORK_DIR
$DOKKU_IMAGE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
builder-dokku-image
dokku deploy
$BUILDER_TYPE
$APP
$SOURCECODE_WORK_DIR
$DOKKU_IMAGE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
builder-release
dokku deploy
$BUILDER_TYPE
$APP
$IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
check-deploy
dokku deploy
$APP $CONTAINER_ID $PROC_TYPE $PORT $IP
#!/usr/bin/env bash
# Disables deploys of containers based on whether the
# `DOKKU_DISABLE_DEPLOY` env var is set to `true` for an app
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
APP="$1"; CONTAINER_ID="$2"; PROC_TYPE="$3"; PORT="$4" ; IP="$5"
eval "$(config_export app $APP)"
DOKKU_DISABLE_DEPLOY="${DOKKU_DISABLE_DEPLOY:-false}"
if [[ "$DOKKU_DISABLE_DEPLOY" = "true" ]]; then
echo -e "\033[31m\033[1mDeploys disabled, sorry.\033[0m"
exit 1
fi
commands help
and commands <PLUGIN_NAME>:help
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.dokku help
and commands <PLUGIN_NAME>:help
#!/usr/bin/env bash
# Outputs help for the derp plugin
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
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
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac
config-export
$APP $GLOBAL $MERGED $FORMAT
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
config-get
$APP $KEY
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
config-get-global
$KEY
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
core-post-deploy
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.
dokku deploy
$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG
#!/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"
core-post-extract
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.
receive-app
plugin trigger$APP
$TMP_WORK_DIR
$REV
#!/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
cron-write
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
# TODO
cron-entries
$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.$DOKKU_SCHEDULER
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
DOKKU_SCHEDULER="$1"
# TODO
dependencies
dokku plugin:install-dependencies
#!/usr/bin/env bash
# Installs nginx for the current plugin
# Supports both opensuse and ubuntu
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
export DEBIAN_FRONTEND=noninteractive
case "$DOKKU_DISTRO" in
debian|raspbian|ubuntu)
apt-get -qq -y --no-install-recommends install nginx
;;
opensuse)
zypper -q in -y nginx
;;
esac
deploy
dokku deploy
$APP [$IMAGE_TAG] [$PROC_TYPE]
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1" IMAGE_TAG="$2" PROC_TYPE="$3"
# TODO
deployed-app-image-repo
dokku/$APP
internal function dokku_deploy_cmd() (deploy phase)
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
# change the repo from dokku/APP to dokkupaas/APP
echo "dokkupaas/$APP"
deployed-app-image-tag
internal function dokku_deploy_cmd() (deploy phase)
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# customize the tag version
echo 'not-latest'
deployed-app-repository
internal function dokku_deploy_cmd() (deploy phase)
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
echo 'derp.dkr.ecr.us-east-1.amazonaws.com'
docker-args-build
Warning: Deprecated, please use
docker-args-process-build
instead
internal function dokku_build() (build phase)
$APP $IMAGE_SOURCE_TYPE
#!/usr/bin/env bash
# Sets a docker build-arg called CACHEBUST which can be used
# to bust cache at any arbitrary point in a Dockerfile build
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
STDIN=$(cat)
APP="$1"; IMAGE_SOURCE_TYPE="$2"
output=""
if [[ "$IMAGE_SOURCE_TYPE" == "dockerfile" ]]; then
output=" --build-arg CACHEBUST=$(date +%s)"
fi
echo -n "$STDIN$output"
docker-args-deploy
Warning: Deprecated, please use
docker-args-process-deploy
instead
dokku deploy
$APP $IMAGE_TAG [$PROC_TYPE $CONTAINER_INDEX]
#!/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
docker-args-process-build
$PROC_TYPE
may be set to magic _all_
process type to signify global docker deploy options.dokku ps:rebuild
$APP $IMAGE_SOURCE_TYPE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_SOURCE_TYPE="$2"
# TODO
docker-args-process-deploy
$PROC_TYPE
may be set to magic _all_
process type to signify global docker deploy options.dokku deploy
$APP $IMAGE_SOURCE_TYPE $IMAGE_TAG [$PROC_TYPE $CONTAINER_INDEX]
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; $IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3"; PROC_TYPE="$4"; CONTAINER_INDEX="$5"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
# TODO
docker-args-process-run
$PROC_TYPE
may be set to magic _all_
process type to signify global docker run options.dokku run
$APP $IMAGE_SOURCE_TYPE $IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_SOURCE_TYPE="$3"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
# TODO
docker-args-run
Warning: Deprecated, please use
docker-args-process-run
instead
dokku run
$APP $IMAGE_TAG
#!/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
domains-add
$APP
$DOMAIN
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
domains-disable
$APP
$RESTART_APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
domains-enable
$APP
$RESTART_APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
domains-list
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
domains-setup
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
domains-vhost-enabled
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-deploy-branch
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-from-archive
git:from-archive
$APP $ARCHIVE_URL $ARCHIVE_TYPE $USER_NAME $USER_EMAIL
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-from-directory
git:from-image
and git:from-archive
$APP $SOURCECODE_WORK_DIR $USER_NAME $USER_EMAIL
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-from-image
git:from-image
$APP $DOCKER_IMAGE $BUILD_DIR $USER_NAME $USER_EMAIL
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-has-code
$APP $BRANCH_NAME
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-post-pull
dokku git-upload-pack
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
git-pre-pull
dokku git-upload-pack
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
Warning: The
git-pre-pull
trigger should not be used for authentication since it does not get called for commands that usegit-upload-archive
such asgit archive
. Instead, use theuser-auth
trigger.
git-revision
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
install
dokku plugin:install
.#!/usr/bin/env bash
# Sets the hostname of the Dokku server
# based on the output of `hostname -f`
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
hostname -f > $DOKKU_ROOT/VHOST
fi
logs-get-property
$APP
$PROPERTY
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PROPERTY="$2"
# TODO
network-build-config
internally triggered by proxy-build-config within proxy implementations
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-clear-config
internally triggered within proxy implementations
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-compute-ports
internally triggered by proxy-build-config within proxy implementations
$APP $PROC_TYPE $IS_HEROKUISH_CONTAINER $CONTAINER_INDEX
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-config-exists
internally triggered by core-post-deploy within proxy implementations
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-get-ipaddr
internally triggered by a deploy
$APP $PROC_TYPE $CONTAINER_ID
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-get-listeners
internally triggered by a deploy
$APP $PROCESS_TYPE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-get-port
internally triggered by a deploy
$APP $PROCESS_TYPE $CONTAINER_ID $IS_HEROKUISH_CONTAINER
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-get-property
internally triggered by a deploy
$APP $KEY
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-get-static-listeners
internally triggered by proxy-build-config
$APP $PROCESS_TYPE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-write-ipaddr
internally triggered by a deploy
$APP $PROC_TYPE $CONTAINER_INDEX $IP_ADDRESS
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
network-write-port
internally triggered by a deploy
$APP $PROC_TYPE $CONTAINER_INDEX $PORT
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
nginx-app-template-source
sigil
template that should be used to generate a given nginx configuration file.nginx-vhosts#build-config
$APP $TEMPLATE_TYPE
TEMPLATE_TYPE
argument can be one of: [app-config, hsts-config, validate-config]
#!/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/
nginx-dokku-template-source
sigil
template that should be used to generate the dokku.conf
nginx configuration file.nginx-vhosts#install
sigil
template can make use of the following variables: $.DOKKU_ROOT $.NGINX_ROOT
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
echo "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku.conf.sigil"
The default template is viewable here: plugins/nginx-vhosts/templates/dokku.conf.sigil
nginx-hostname
dokku domains:setup
$APP $SUBDOMAIN $VHOST
#!/usr/bin/env bash
# Reverses the hostname for the app
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; SUBDOMAIN="$2"; VHOST="$3"
NEW_SUBDOMAIN=`echo $SUBDOMAIN | rev`
echo "$NEW_SUBDOMAIN.$VHOST"
nginx-pre-reload
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 ofnginx-pre-reload
in order to retrieve all application listeners.
dokku nginx:build-config
$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS
#!/usr/bin/env bash
# Runs a check against all nginx conf files
# to ensure they are valid
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
nginx -t
post-app-clone
dokku apps:clone
$OLD_APP_NAME $NEW_APP_NAME
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-app-clone-setup
dokku apps:clone
$OLD_APP_NAME $NEW_APP_NAME
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-app-rename
dokku apps:rename
$OLD_APP_NAME $NEW_APP_NAME
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-app-rename-setup
dokku apps:rename
$OLD_APP_NAME $NEW_APP_NAME
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-build-buildpack
internal function dokku_build() (build phase)
$APP
$SOURCECODE_WORK_DIR
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-build-pack
Warning: The pack plugin trigger apis are under development and may change between minor releases until the 1.0 release.
internal function dokku_build() (build phase)
$APP
$SOURCECODE_WORK_DIR
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-build-dockerfile
internal function dokku_build() (build phase)
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-certs-remove
dokku certs:remove
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
# TODO
post-certs-update
dokku certs:add
, dokku certs:update
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
# TODO
post-config-update
set
or unset
.dokku config:set
, dokku config:unset
$APP
set|unset
key1=VALUE1 key2=VALUE2
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-container-create
dokku run
, dokku ps:rebuild
, dokku deploy
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
post-create
dokku apps:create
$APP
#!/usr/bin/env bash
# Runs a command to ensure that an app
# has a postgres database when it is starting
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
POSTGRES="$1"
dokku postgres:create $POSTGRES
dokku postgres:link $POSTGRES $APP
post-delete
dokku apps:destroy
$APP $IMAGE_TAG
#!/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
post-deploy
Please see core-post-deploy if contributing a core plugin with the
post-deploy
hook.
core-post-deploy
. Deployment Tasks are also invoked by this plugin trigger.dokku deploy
$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG
#!/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"
post-domains-update
dokku domains:add
, dokku domains:clear
, dokku domains:remove
, dokku domains:set
$APP
action name
domains
#!/usr/bin/env bash
# Reloads haproxy for our imaginary haproxy plugin
# that replaces the nginx-vhosts plugin
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
sudo service haproxy reload
post-extract
receive-app
plugin trigger$APP
$TMP_WORK_DIR
$REV
#!/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
post-proxy-ports-update
dokku proxy:ports-add
, dokku proxy:ports-clear
, dokku proxy:ports-remove
$APP
action name
#!/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"
APP="$1"
haproxy-build-config "$APP"
post-release-builder
Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
$BUILDER_TYPE $APP $IMAGE
#!/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
post-release-buildpack
Warning: Deprecated, please use
post-release-builder
instead Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/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
post-release-pack
Warning: Deprecated, please use
post-release-builder
instead
Warning: The pack plugin trigger apis are under development and may change 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.
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/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
post-release-dockerfile
Warning: Deprecated, please use
post-release-builder
instead
Warning: Image mutation in this trigger may result in an invalid run state, and is heavily discouraged.
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/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
post-stop
dokku ps:stop
$APP
#!/usr/bin/env bash
# Marks an app as manually stopped
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
dokku config:set --no-restart $APP MANUALLY_STOPPED=1
pre-build-buildpack
internal function dokku_build() (build phase)
$APP
$SOURCECODE_WORK_DIR
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
pre-build-pack
Warning: The pack plugin trigger apis are under development and may change between minor releases until the 1.0 release.
internal function dokku_build() (build phase)
$APP
$SOURCECODE_WORK_DIR
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
pre-build-dockerfile
internal function dokku_build() (build phase)
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
pre-delete
dokku apps:destroy
$APP $IMAGE_TAG
#!/usr/bin/env bash
# Clears out the gulp asset build cache for apps
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; GULP_CACHE_DIR="$DOKKU_ROOT/$APP/gulp"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
if [[ -d $GULP_CACHE_DIR ]]; then
docker run "${DOCKER_COMMIT_LABEL_ARGS[@]}" --rm -v "$GULP_CACHE_DIR:/gulp" "$IMAGE" find /gulp -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true
fi
pre-deploy
dokku deploy
$APP $IMAGE_TAG
#!/usr/bin/env bash
# Runs gulp in our 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)
dokku_log_info1 "Running gulp"
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
pre-disable-vhost
dokku domains:disable
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
# TODO
pre-enable-vhost
dokku domains:enable
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"
# TODO
pre-receive-app
IMAGE_SOURCE_TYPE
can be any of [herokuish, dockerfile]
dokku git-hook
, dokku tar-build-locked
$APP $IMAGE_SOURCE_TYPE $TMP_WORK_DIR $REV
#!/usr/bin/env bash
# Adds a file called `dokku-is-awesome` to the repository
# the contents will be the app name
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE_SOURCE_TYPE="$2"; TMP_WORK_DIR="$3"; REV="$4"
echo "$APP" > "$TMP_WORK_DIR/dokku-is-awesome"
pre-release-buildpack
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/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)
dokku_log_info1 "Installing GraphicsMagick..."
CMD="cat > gm && \
dpkg -s graphicsmagick >/dev/null 2>&1 || \
(apt-get update -qq && apt-get -qq -y --no-install-recommends install graphicsmagick && apt-get clean)"
CID=$(docker run $DOKKU_GLOBAL_RUN_ARGS -i -a stdin $IMAGE /bin/bash -c "$CMD")
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
pre-release-pack
Warning: The pack plugin trigger apis are under development and may change between minor releases until the 1.0 release.
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; IMAGE_TAG="$2";
# TODO
pre-release-dockerfile
internal function dokku_release() (release phase)
$APP $IMAGE_TAG
#!/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
pre-restore
dokku ps:restore
$DOKKU_SCHEDULER $APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"
# TODO
pre-start
dokku ps:start
$APP
#!/usr/bin/env bash
# Notifies an example url that an app is starting
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
curl "https://dokku.me/starting/${APP}" || true
procfile-extract
internally
$APP $IMAGE
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
procfile-get-command
internally
$APP $PROCESS_TYPE $PORT
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
procfile-remove
internally
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-build-config
internally triggered by ps:restore
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-clear-config
internally triggered by apps:rename
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-disable
internally triggered by ps:restore
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-enable
internally triggered by ps:restore
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-is-enabled
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
proxy-type
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
ps-can-scale
ps:scale
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
ps-current-scale
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
ps-set-scale
$APP $SKIP_DEPLOY $CLEAR_EXISTING [$PROCESS_TUPLE...]
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
receive-app
dokku git-hook
, dokku ps:rebuild
$APP $REV
($REV
may not be included in cases where a repository is not pushed)#!/usr/bin/env bash
# For our imaginary mercurial plugin, triggers a rebuild
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; REV="$2"
dokku hg-build $APP $REV
receive-branch
dokku git-hook
, dokku ps:rebuild
$APP $REV $REFNAME
#!/bin/bash
# Gives Dokku the ability to support multiple branches for a given service
# 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
REFERENCE_REPO="$DOKKU_ROOT/$reference_app"
git clone --bare --shared --reference "$REFERENCE_REPO" "$REFERENCE_REPO" "$DOKKU_ROOT/$APP" >/dev/null
fi
plugn trigger receive-app $APP $newrev
release-and-deploy
$APP $IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
# TODO
report
dokku report
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
# TODO
resource-get-property
$APP
$PROC_TYPE
$RESOURCE_TYPE
$PROPERTY
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; PROC_TYPE="$2" RESOURCE_TYPE="$3" PROPERTY="$4"
# TODO
retire-container-failed
dokku deploy
$APP
#!/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)
mail -s "$APP containers on $HOSTNAME failed to retire" ops@dokku.me
scheduler-app-status
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku ps:report
$DOKKU_SCHEDULER $APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
scheduler-deploy
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku deploy
$DOKKU_SCHEDULER $APP $IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_TAG="$3";
# TODO
scheduler-detect
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku deploy
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
# TODO
scheduler-enter
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku enter
$DOKKU_SCHEDULER $APP $@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; ARGS="$@"
# TODO
scheduler-inspect
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku ps:inspect
$DOKKU_SCHEDULER $APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
scheduler-logs
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku logs:failed
$DOKKU_SCHEDULER $APP $PROCESS_TYPE $TAIL $PRETTY_PRINT $NUM
#!/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
scheduler-logs-failed
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku logs:failed
$DOKKU_SCHEDULER $APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
scheduler-post-delete
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku apps:destroy
$DOKKU_SCHEDULER $APP $IMAGE_TAG
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_TAG="$3";
# TODO
scheduler-post-run
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku run
invocation is calleddokku run
$DOKKU_SCHEDULER $APP $CONTAINER_ID
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; CONTAINER_ID="$3";
# TODO
scheduler-register-retired
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
internally
$APP $CONTAINER_ID
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1";
CONTAINER_ID="$2";
# TODO
scheduler-retire
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku run
$DOKKU_SCHEDULER $APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2";
# TODO
scheduler-run
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku run
$DOKKU_SCHEDULER $APP ...ARGS
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; ARGS="${@:3}";
# TODO
scheduler-stop
Warning: The scheduler plugin trigger apis are under development and may change between minor releases until the 1.0 release.
dokku apps:destroy, dokku ps:stop
$DOKKU_SCHEDULER $APP $REMOVE_CONTAINERS
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
DOKKU_SCHEDULER="$1"; APP="$2"; REMOVE_CONTAINERS="$3";
# TODO
storage-list
dokku storage:list
and dokku deploy
$APP
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
# TODO
uninstall
dokku plugin:uninstall
$PLUGIN
#!/usr/bin/env bash
# Cleanup up extra containers created
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
PLUGIN="$1"
[[ "$PLUGIN" = "my-plugin" ]] && docker rmi -f "${PLUGIN_IMAGE_DEPENDENCY}"
To avoid uninstalling other plugins make sure to check the plugin name like shown in the example.
update
dokku plugin:update
.#!/usr/bin/env bash
# Update the herokuish image from git source
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
cd /root/dokku
sudo BUILD_STACK=true make install
user-auth
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.
Note that the trigger should exit as follows:
0
to continue running as normal1
to halt execution of the commandThe 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.).
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:
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.
dokku
$SSH_USER $SSH_NAME $DOKKU_COMMAND
#!/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
user-auth-app
This is a special plugin trigger that is executed when listing apps or checking if an app exists. All Dokku commands should check if an app exists at least once before interacting with them so as not to circumvent the check.
Note that the trigger should exit 0
, and each non-empty line on stdout is captured as a valid app name.
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.).
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:
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.
dokku
$SSH_USER $SSH_NAME $DOKKU_COMMAND
#!/usr/bin/env bash
# hide any apps with the prefix "admin"
# if the logged in user (SSH_USER) or SSH_NAME is not `root`
main() {
declare SSH_USER="$1" SSH_NAME="$2" ARGS=("${@:3}")
for arg in "${ARGS[@]}"; do
if [[ "$arg" == admin-* ]] && [[ "$SSH_USER" != "root" ]] && [[ "$SSH_NAME" != "root" ]]; then
continue
fi
echo "${arg}"
done
}
main "$@"