Files
dokku/plugins/scheduler-docker-local/post-delete
Jose Diaz-Gonzalez 785d9b4937 feat: allow setting DOCKER_BIN path for docker execution
This change allows operators to specify a DOCKER_BIN environment variable. This will specify a binary to run when executing docker, which is useful in cases where the 'docker' command being run must be modified in a way that would otherwise be invasive to Dokku, but minimalistic if done within a wrapper.
2019-05-29 00:46:19 -04:00

32 lines
1012 B
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
scheduler-docker-local-post-delete() {
declare desc="scheduler-docker-local post-delete plugin trigger"
declare trigger="scheduler-docker-local post-delete"
declare APP="$1"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
local IMAGE_REPO=$(get_app_image_repo "$APP")
# remove all application containers & images
# shellcheck disable=SC2046
local DOKKU_APP_CIDS=$("$DOCKER_BIN" ps -a --no-trunc | egrep "dokku/${APP}:" | awk '{ print $1 }' | xargs)
if [[ -n "$DOKKU_APP_CIDS" ]]; then
# shellcheck disable=SC2086
"$DOCKER_BIN" rm -f $DOKKU_APP_CIDS >/dev/null 2>&1 || true
fi
# shellcheck disable=SC2046
"$DOCKER_BIN" rmi $("$DOCKER_BIN" images -q "$IMAGE_REPO" | xargs) &>/dev/null || true
}
scheduler-docker-local-post-delete "$@"