这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/development/plugin-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,27 @@ docker commit $id $IMAGE > /dev/null
dokku_log_info1 "Building UI Complete"
```

### `post-create`

- Description: Can be used to run commands after an application is created.
- Invoked by: `dokku apps:create`
- Arguments: `$APP`
- Example:

```shell
#!/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-deploy`

- Description: Allows running of commands after a deploy has completed. Dokku core currently uses this to switch traffic on nginx.
Expand Down
8 changes: 2 additions & 6 deletions plugins/apps/commands
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[[ " apps apps:create apps:destroy help apps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"

case "$1" in
apps)
Expand All @@ -10,12 +11,7 @@ case "$1" in
;;

apps:create)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_fail "Name is already taken"
APP="$2"

mkdir -p "$DOKKU_ROOT/$APP"
echo "Creating $APP... done"
apps_create $2
;;

apps:destroy)
Expand Down
13 changes: 13 additions & 0 deletions plugins/apps/functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"

apps_create() {
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -d "$DOKKU_ROOT/$1" ]] && dokku_log_fail "Name is already taken"
local APP="$1"

mkdir -p "$DOKKU_ROOT/$APP"
echo "Creating $APP... done"
plugn trigger post-create $APP
}
2 changes: 2 additions & 0 deletions plugins/git/commands
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/apps/functions"

git_build_app_repo() {
verify_app_name "$1"
Expand All @@ -14,6 +15,7 @@ git_build_app_repo() {
chmod 755 $TMP_WORK_DIR
unset GIT_DIR GIT_WORK_TREE
pushd $TMP_WORK_DIR > /dev/null
[[ ! -d "$DOKKU_ROOT/$APP" ]] && apps_create $APP
git clone -q "$DOKKU_ROOT/$APP" "$TMP_WORK_DIR" &> /dev/null
git config advice.detachedHead false
git checkout "$REV" &> /dev/null
Expand Down