docker-deploy.sh: --no-cache wieder Standard, --cache als Opt-out
This commit is contained in:
1 parent
9a8469db6f
commit
896d38fd63
1 file changed
+9
-7
+9
-7
@@ -17,10 +17,10 @@ die() { printf '❌ %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
usage() {
|
||||
cat >&2 <<EOF
|
||||
Verwendung: sudo ${SCRIPT_NAME} <username> <action> [--no-cache]
|
||||
Verwendung: sudo ${SCRIPT_NAME} <username> <action> [--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"
|
||||
|
||||
Reference in new issue
Block a user