-
Notifications
You must be signed in to change notification settings - Fork 13
/
functions
51 lines (39 loc) · 1.42 KB
/
functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_ENABLED_PATH/common/functions"
APP="$1"
IMAGE=$(get_app_image_name $APP)
# Almost the same as dokku run, except it uses $APP:latest image
function run() {
if [[ -z "$DOKKU_RM_CONTAINER" ]]; then
DOKKU_APP_RM_CONTAINER=$(dokku config:get $APP DOKKU_RM_CONTAINER || true)
DOKKU_GLOBAL_RM_CONTAINER=$(dokku config:get --global DOKKU_RM_CONTAINER || true)
DOKKU_RM_CONTAINER=${DOKKU_APP_RM_CONTAINER:="$DOKKU_GLOBAL_RM_CONTAINER"}
fi
DOCKER_ARGS=$(: | plugn trigger docker-args-run $APP $IMAGE_TAG)
[[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true "
[[ "$DOKKU_RM_CONTAINER" ]] && DOKKU_RUN_OPTS="--rm"
has_tty && DOKKU_RUN_OPTS+=" -i -t"
is_image_herokuish_based "$IMAGE" && EXEC_CMD="/exec"
docker run $DOKKU_GLOBAL_RUN_ARGS $DOKKU_RUN_OPTS $DOCKER_ARGS $IMAGE $EXEC_CMD "$@"
}
function execute_hooks() {
local hooks_path="$1"
echo $hooks_path
if ! run test -f $hooks_path; then
echo " $hooks_path not found or executable bit not set. Skipping ..."
return
fi
echo " $hooks_path file found. Running it ..."
run $hooks_path
}
function execute_host_hooks() {
local hooks_path="$1"
echo $hooks_path
if ! test -x $hooks_path; then
echo " $hooks_path not found or executable bit not set. Skipping ..."
return
fi
echo " $hooks_path file found. Running it ..."
. $hooks_path
}