Merge pull request #2822 from dokku/refactor-cleanup
refactor: allow skipping cleanup on a per-application basis
This commit is contained in:
commit
4f6e714a9d
3 files changed
+17
-8
No files matched your search
@@ -105,7 +105,7 @@ The following list config variables have special meaning and can be set in a var
|
|||||||
| `DOKKU_NGINX_SSL_PORT` | automatically assigned | `dokku config:set` | |
|
| `DOKKU_NGINX_SSL_PORT` | automatically assigned | `dokku config:set` | |
|
||||||
| `DOKKU_PROXY_PORT_MAP` | automatically assigned | `dokku proxy:ports-add` <br /> `dokku proxy:ports-remove`, `dokku proxy:ports-clear` | |
|
| `DOKKU_PROXY_PORT_MAP` | automatically assigned | `dokku proxy:ports-add` <br /> `dokku proxy:ports-remove`, `dokku proxy:ports-clear` | |
|
||||||
| `DOKKU_SKIP_ALL_CHECKS` | none | `dokku config:set` | |
|
| `DOKKU_SKIP_ALL_CHECKS` | none | `dokku config:set` | |
|
||||||
| `DOKKU_SKIP_CLEANUP` | | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | |
|
| `DOKKU_SKIP_CLEANUP` | | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | When a deploy is triggered, if this is set to a non-empty value, then old docker containers and images will not be removed. |
|
||||||
| `DOKKU_SKIP_DEFAULT_CHECKS` | | `dokku config:set` | |
|
| `DOKKU_SKIP_DEFAULT_CHECKS` | | `dokku config:set` | |
|
||||||
| `DOKKU_SKIP_DEPLOY` | | `dokku config:set` | |
|
| `DOKKU_SKIP_DEPLOY` | | `dokku config:set` | |
|
||||||
| `DOKKU_WAIT_TO_RETIRE` | `60` | `dokku config:set` | After a successful deploy, the grace period given to old containers before they are stopped/terminated. This is useful for ensuring completion of long-running http connections. |
|
| `DOKKU_WAIT_TO_RETIRE` | `60` | `dokku config:set` | After a successful deploy, the grace period given to old containers before they are stopped/terminated. This is useful for ensuring completion of long-running http connections. |
|
||||||
@@ -6,7 +6,7 @@ dokku_cleanup_cmd(){
|
|||||||
declare desc="cleans up old deployment cruft"
|
declare desc="cleans up old deployment cruft"
|
||||||
local cmd="cleanup"
|
local cmd="cleanup"
|
||||||
|
|
||||||
docker_cleanup
|
docker_cleanup "$APP" "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -746,12 +746,8 @@ dokku_receive() {
|
|||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
local APP="$1"; local IMAGE=$(get_app_image_name "$APP"); local IMAGE_SOURCE_TYPE="$2"; local TMP_WORK_DIR="$3"
|
local APP="$1"; local IMAGE=$(get_app_image_name "$APP"); local IMAGE_SOURCE_TYPE="$2"; local TMP_WORK_DIR="$3"
|
||||||
if [[ -z "$DOKKU_SKIP_CLEANUP" ]]; then
|
local DOKKU_SKIP_CLEANUP="$(config_get "$APP" DOKKU_SKIP_CLEANUP || true)"
|
||||||
dokku_log_info1 "Cleaning up..."
|
docker_cleanup "$APP"
|
||||||
docker_cleanup
|
|
||||||
else
|
|
||||||
dokku_log_info1 "DOKKU_SKIP_CLEANUP set. Skipping dokku cleanup"
|
|
||||||
fi
|
|
||||||
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..."
|
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..."
|
||||||
config_set --no-restart "$APP" DOKKU_APP_TYPE="$IMAGE_SOURCE_TYPE" &> /dev/null
|
config_set --no-restart "$APP" DOKKU_APP_TYPE="$IMAGE_SOURCE_TYPE" &> /dev/null
|
||||||
dokku_build "$APP" "$IMAGE_SOURCE_TYPE" "$TMP_WORK_DIR"
|
dokku_build "$APP" "$IMAGE_SOURCE_TYPE" "$TMP_WORK_DIR"
|
||||||
@@ -760,6 +756,19 @@ dokku_receive() {
|
|||||||
|
|
||||||
docker_cleanup() {
|
docker_cleanup() {
|
||||||
declare desc="cleans up all exited/dead containers and removes all dangling images"
|
declare desc="cleans up all exited/dead containers and removes all dangling images"
|
||||||
|
declare APP="$1" FORCE_CLEANUP="$2"
|
||||||
|
local DOKKU_APP_SKIP_CLEANUP
|
||||||
|
|
||||||
|
if [[ "$FORCE_CLEANUP" != "true" ]]; then
|
||||||
|
[[ -z "$APP" ]] && DOKKU_APP_SKIP_CLEANUP="$(config_get "$APP" DOKKU_SKIP_CLEANUP || true)"
|
||||||
|
if [[ -n "$DOKKU_SKIP_CLEANUP" ]] || [[ -n "$DOKKU_APP_SKIP_CLEANUP" ]]; then
|
||||||
|
dokku_log_info1 "DOKKU_SKIP_CLEANUP set. Skipping dokku cleanup"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_info1 "Cleaning up..."
|
||||||
|
|
||||||
# delete all non-running containers
|
# delete all non-running containers
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
docker rm $(docker ps -a -f "status=exited" -f "label=$DOKKU_CONTAINER_LABEL" -q) &> /dev/null || true
|
docker rm $(docker ps -a -f "status=exited" -f "label=$DOKKU_CONTAINER_LABEL" -q) &> /dev/null || true
|
||||||
|
|||||||
Reference in new issue
Block a user