Add post-create hook
Note that this is invoked *before* the application is deployed, so it's usage is quite different than a potential post-successful-create hook.
This commit is contained in:
@@ -380,6 +380,27 @@ docker commit $id $IMAGE > /dev/null
|
|||||||
dokku_log_info1 "Building UI Complete"
|
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`
|
### `post-deploy`
|
||||||
|
|
||||||
- Description: Allows running of commands after a deploy has completed. Dokku core currently uses this to switch traffic on nginx.
|
- Description: Allows running of commands after a deploy has completed. Dokku core currently uses this to switch traffic on nginx.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
[[ " apps apps:create apps:destroy help apps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
[[ " apps apps:create apps:destroy help apps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
apps)
|
apps)
|
||||||
@@ -10,12 +11,7 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
apps:create)
|
apps:create)
|
||||||
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
apps_create $2
|
||||||
[[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_fail "Name is already taken"
|
|
||||||
APP="$2"
|
|
||||||
|
|
||||||
mkdir -p "$DOKKU_ROOT/$APP"
|
|
||||||
echo "Creating $APP... done"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
apps:destroy)
|
apps:destroy)
|
||||||
|
|||||||
13
plugins/apps/functions
Executable file
13
plugins/apps/functions
Executable file
@@ -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
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||||
|
|
||||||
git_build_app_repo() {
|
git_build_app_repo() {
|
||||||
verify_app_name "$1"
|
verify_app_name "$1"
|
||||||
@@ -14,6 +15,7 @@ git_build_app_repo() {
|
|||||||
chmod 755 $TMP_WORK_DIR
|
chmod 755 $TMP_WORK_DIR
|
||||||
unset GIT_DIR GIT_WORK_TREE
|
unset GIT_DIR GIT_WORK_TREE
|
||||||
pushd $TMP_WORK_DIR > /dev/null
|
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 clone -q "$DOKKU_ROOT/$APP" "$TMP_WORK_DIR" &> /dev/null
|
||||||
git config advice.detachedHead false
|
git config advice.detachedHead false
|
||||||
git checkout "$REV" &> /dev/null
|
git checkout "$REV" &> /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user