From 896d38fd63a9275b68ea45ac03b70db9d18ebb52 Mon Sep 17 00:00:00 2001 From: Jochen Mehlich Date: Sat, 24 Oct 2026 09:58:06 +0200 Subject: [PATCH] docker-deploy.sh: --no-cache wieder Standard, --cache als Opt-out --- docker-deploy.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docker-deploy.sh b/docker-deploy.sh index 4846f0d..b07c3a8 100644 --- a/docker-deploy.sh +++ b/docker-deploy.sh @@ -17,10 +17,10 @@ die() { printf '❌ %s\n' "$*" >&2; exit 1; } usage() { cat >&2 < [--no-cache] +Verwendung: sudo ${SCRIPT_NAME} [--cache] Aktionen: ${ALLOWED_ACTIONS[*]} -Optionen: --no-cache Build ohne Layer-Cache (nur build/deploy) +Optionen: --cache Build mit Layer-Cache (Standard bei build/deploy: --no-cache) Beispiel: sudo ${SCRIPT_NAME} func_123 deploy EOF @@ -52,9 +52,11 @@ trap 'on_error $LINENO' ERR APP_USER="$1" ACTION="$2" -NO_CACHE=() -if [[ "${3:-}" == "--no-cache" ]]; then - NO_CACHE=(--no-cache) +NO_CACHE=(--no-cache) +USE_CACHE=false +if [[ "${3:-}" == "--cache" ]]; then + NO_CACHE=() + USE_CACHE=true elif [[ -n "${3:-}" ]]; then usage fi @@ -65,8 +67,8 @@ fi id "$APP_USER" &>/dev/null || die "User '$APP_USER' existiert nicht auf diesem System" user_in_group "$APP_USER" "$DEPLOY_GROUP" || die "User '$APP_USER' ist nicht in Gruppe '$DEPLOY_GROUP'" in_array "$ACTION" "${ALLOWED_ACTIONS[@]}" || die "Unbekannte Aktion: '$ACTION' (erlaubt: ${ALLOWED_ACTIONS[*]})" -if [[ ${#NO_CACHE[@]} -gt 0 && "$ACTION" != "build" && "$ACTION" != "deploy" ]]; then - die "--no-cache ist nur bei build/deploy sinnvoll" +if $USE_CACHE && [[ "$ACTION" != "build" && "$ACTION" != "deploy" ]]; then + die "--cache ist nur bei build/deploy sinnvoll" fi command -v docker >/dev/null || die "docker nicht gefunden"