diff --git a/plugins/00_dokku-standard/exec-app-json-scripts b/plugins/00_dokku-standard/exec-app-json-scripts index e9b6f4bcb..268f55e7b 100755 --- a/plugins/00_dokku-standard/exec-app-json-scripts +++ b/plugins/00_dokku-standard/exec-app-json-scripts @@ -51,6 +51,7 @@ execute_script() { COMMAND+=" fi " local CACHE_DIR="$DOKKU_ROOT/$APP/cache" + local CACHE_DIR_ON_HOST="$DOKKU_ROOT_ON_HOST/$APP/cache" [[ -d $CACHE_DIR ]] || mkdir -p "$CACHE_DIR" local DOCKER_ARGS=$(: | plugn trigger docker-args-deploy "$APP" "$IMAGE_TAG") @@ -66,7 +67,7 @@ execute_script() { DOKKU_APP_SHELL="$(config_get "$APP" DOKKU_APP_SHELL || echo "$DOKKU_APP_SHELL")" [[ -z "$DOKKU_APP_SHELL" ]] && DOKKU_APP_SHELL="/bin/bash" - id=$(docker run "$DOKKU_GLOBAL_RUN_ARGS" -e DOKKU_TRACE="$DOKKU_TRACE" --label=dokku_phase_script="${PHASE_SCRIPT_KEY}" -d -v "$CACHE_DIR:/cache" "${ARG_ARRAY[@]}" "$IMAGE" "$DOKKU_APP_SHELL" -c "$COMMAND") + id=$(docker run "$DOKKU_GLOBAL_RUN_ARGS" -e DOKKU_TRACE="$DOKKU_TRACE" --label=dokku_phase_script="${PHASE_SCRIPT_KEY}" -d -v "$CACHE_DIR_ON_HOST:/cache" "${ARG_ARRAY[@]}" "$IMAGE" "$DOKKU_APP_SHELL" -c "$COMMAND") if test "$(docker wait "$id")" -eq 0; then dokku_container_log_verbose_quiet "$id" if [[ "$PHASE_SCRIPT_KEY" != "postdeploy" ]];then diff --git a/plugins/apps/pre-delete b/plugins/apps/pre-delete index 8fe4e5fe2..c98cf215e 100755 --- a/plugins/apps/pre-delete +++ b/plugins/apps/pre-delete @@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" apps_pre_delete() { declare desc="apps pre-delete plugin trigger" local trigger="apps_pre_delete" - local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG"); local CACHE_DIR="$DOKKU_ROOT/$APP/cache" + local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_deploying_app_image_name "$APP" "$IMAGE_TAG"); local CACHE_DIR="$DOKKU_ROOT/$APP/cache"; local CACHE_DIR_ON_HOST="$DOKKU_ROOT_ON_HOST/$APP/cache" verify_app_name "$APP" if ! is_image_herokuish_based "$IMAGE"; then @@ -13,7 +13,7 @@ apps_pre_delete() { fi if [[ -d $CACHE_DIR ]]; then - docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$CACHE_DIR:/cache" "$IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true + docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$CACHE_DIR_ON_HOST:/cache" "$IMAGE" find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} \; || true fi } diff --git a/plugins/apps/subcommands/clone b/plugins/apps/subcommands/clone index 1223aeb32..b08f0f268 100755 --- a/plugins/apps/subcommands/clone +++ b/plugins/apps/subcommands/clone @@ -19,6 +19,7 @@ apps_clone_cmd() { [[ -z "$OLD_APP" ]] && dokku_log_fail "Please specify an app to run the command on" [[ -d "$DOKKU_ROOT/$NEW_APP" ]] && dokku_log_fail "Name is already taken" local NEW_CACHE_DIR="$DOKKU_ROOT/$NEW_APP/cache" + local NEW_CACHE_DIR_ON_HOST="$DOKKU_ROOT_ON_HOST/$NEW_APP/cache" apps_create "$NEW_APP" pushd "$DOKKU_ROOT/$OLD_APP/." > /dev/null @@ -26,7 +27,7 @@ apps_clone_cmd() { popd > /dev/null 2>&1 || pushd "/tmp" > /dev/null if [[ -d "$NEW_CACHE_DIR" ]] && ! rmdir "$NEW_CACHE_DIR"; then - docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$NEW_CACHE_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache + docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$NEW_CACHE_DIR_ON_HOST:/cache" "dokku/$OLD_APP" chmod 777 -R /cache fi rm -rf "$NEW_CACHE_DIR" diff --git a/plugins/apps/subcommands/rename b/plugins/apps/subcommands/rename index 34da3df31..2fb9248ed 100755 --- a/plugins/apps/subcommands/rename +++ b/plugins/apps/subcommands/rename @@ -12,9 +12,10 @@ apps_rename_cmd() { local OLD_APP="$2" local NEW_APP="$3" local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache" + local OLD_CACHE_DIR_ON_HOST="$DOKKU_ROOT_ON_HOST/$OLD_APP/cache" if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR"; then - docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache + docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_DIR_ON_HOST:/cache" "dokku/$OLD_APP" chmod 777 -R /cache fi rm -rf "$OLD_CACHE_DIR" apps_create "$NEW_APP" diff --git a/plugins/common/functions b/plugins/common/functions index 725a3eae2..7d1d85112 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -434,6 +434,7 @@ dokku_build() { verify_app_name "$APP" local DOKKU_APP_CACHE_DIR="$DOKKU_ROOT/$APP/cache" + local DOKKU_APP_CACHE_DIR_ON_HOST="$DOKKU_ROOT_ON_HOST/$APP/cache" eval "$(config_export app "$APP")" pushd "$TMP_WORK_DIR" &> /dev/null @@ -452,7 +453,7 @@ dokku_build() { declare -a ARG_ARRAY eval "ARG_ARRAY=($DOCKER_ARGS)" # shellcheck disable=SC2086 - cid=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -v $DOKKU_APP_CACHE_DIR:/cache -e CACHE_PATH=/cache "${ARG_ARRAY[@]}" $IMAGE /build) + cid=$(docker run $DOKKU_GLOBAL_RUN_ARGS -d -v $DOKKU_APP_CACHE_DIR_ON_HOST:/cache -e CACHE_PATH=/cache "${ARG_ARRAY[@]}" $IMAGE /build) docker attach "$cid" test "$(docker wait "$cid")" -eq 0 docker commit "$cid" "$IMAGE" > /dev/null diff --git a/plugins/repo/src/subcommands/purge-cache/purge-cache.go b/plugins/repo/src/subcommands/purge-cache/purge-cache.go index 29b04cd75..bf1998e42 100644 --- a/plugins/repo/src/subcommands/purge-cache/purge-cache.go +++ b/plugins/repo/src/subcommands/purge-cache/purge-cache.go @@ -21,11 +21,12 @@ func main() { } cacheDir := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName, "cache"}, "/") + cacheDirOnHost := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT_ON_HOST"), appName, "cache"}, "/") dokkuGlobalRunArgs := common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS") image := common.GetDeployingAppImageName(appName, "", "") if info, _ := os.Stat(cacheDir); info != nil && info.IsDir() { purgeCacheCmd := common.NewShellCmd(strings.Join([]string{"docker run --rm", dokkuGlobalRunArgs, - "-v", strings.Join([]string{cacheDir, ":/cache"}, ""), image, + "-v", strings.Join([]string{cacheDirOnHost, ":/cache"}, ""), image, `find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} ;`}, " ")) purgeCacheCmd.Execute() err := os.MkdirAll(cacheDir, 0644)