Previously, we would filter containers and images by name, which could be fail if the app was renamed or no longer was tagged "correctly" due to a rebuild. Now, we filter by label, ensuring an app is completely cleaned up on deletion. Also: - Move docker image cleanup from apps plugin to builder plugin: This isn't where it belongs - images should be cleaned up in a builder plugin (or the builders plugin) and not in the apps plugin, which has nothing to do with docker images anyways. - Remove the code from the scheduler plugin, as that will only do anything if the scheduler is enabled for the app. - Bypass image removal if there are no images to remove - Always delete app containers: The herokuish builder creates intermediate build containers - something that should be refactored - and ideally this gets run in that builder plugin, but keeping the logic here ensures we don't have code duplication. This is otherwise safe as it will be a no-op if there are no containers to clean up.
21 lines
744 B
Bash
Executable File
21 lines
744 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
|
|
|
trigger-scheduler-docker-local-post-delete() {
|
|
declare desc="scheduler-docker-local post-delete plugin trigger"
|
|
declare trigger="post-delete"
|
|
declare APP="$1"
|
|
|
|
fn-plugin-property-destroy "scheduler-docker-local" "$APP"
|
|
rm -rf "${DOKKU_LIB_ROOT}/data/scheduler-docker-local/$APP"
|
|
|
|
# remove all application containers
|
|
# shellcheck disable=SC2046
|
|
"$DOCKER_BIN" container ls --filter "label=com.dokku.app-name=${APP}" -q | xargs -n1 -I {} "$DOCKER_BIN" container rm --force {} &>/dev/null || true
|
|
}
|
|
|
|
trigger-scheduler-docker-local-post-delete "$@"
|