#!/usr/bin/env bash log() { local message="$1" echo -e "\033[32mLog: $message\033[0m" } handle_error() { local error_message="$1" echo -e "\033[31mError: $error_message\033[0m" exit 1 } # Retry logic with exponential backoff # Usage: retry # e.g.: retry docker compose down --volumes retry() { local max_attempts=5 local attempt=1 local delay=1 while true; do "$@" && break || { if [ $attempt -lt $max_attempts ]; then log "Command failed (attempt $attempt/$max_attempts). Retrying in $delay seconds..." sleep $delay delay=$((delay * 2)) ((attempt++)) else handle_error "Command failed after $attempt attempts: $*" fi } done } ################################################################################ # MAIN ################################################################################ if [ "$1" == "push" ]; then start: docker login -u="merms" -p="may12002!" registry.chiefsoft.com docker tag mermsicare-mermshosted-icare registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest docker push registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest elif [ "$1" == "test" ]; then start: docker images else handle_error "Invalid argument. Use 'dev' or 'test'." fi