fix(build.sh): update image tag handling to prompt interactively if omitted

- Modified the build script to allow the image tag to be optional, prompting the user for input if not provided.
- Updated usage instructions to reflect the new behavior.
This commit is contained in:
AmirReza Jamali
2026-04-26 16:14:58 +03:30
parent 36cf088aa5
commit 1540679095
2 changed files with 20 additions and 6 deletions
+14 -4
View File
@@ -6,10 +6,10 @@ cd "$ROOT_DIR"
usage() {
cat <<EOF >&2
Usage: $(basename "$0") <tag> [service]
Usage: $(basename "$0") [tag] [service]
Arguments:
tag Image tag (required), e.g. 200-develop
tag Image tag (if omitted, asked interactively), e.g. 200-develop
service Service name (default: web)
Environment variables:
@@ -20,6 +20,7 @@ Environment variables:
PUSH Set to 1 to docker push after build (default: 0)
Examples:
$(basename "$0")
$(basename "$0") 200-develop
RUN_BUILD=1 $(basename "$0") 200-develop
$(basename "$0") 200-develop web
@@ -28,11 +29,11 @@ EOF
exit 1
}
if [[ $# -lt 1 || "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
fi
TAG="$1"
TAG="${1:-}"
SERVICE="${2:-web}"
REGISTRY="${REGISTRY:-ovh-docker.aectest.ir}"
PROJECT="${PROJECT:-tm}"
@@ -40,6 +41,15 @@ DOCKERFILE="${DOCKERFILE:-$ROOT_DIR/Dockerfile}"
RUN_BUILD="${RUN_BUILD:-0}"
PUSH="${PUSH:-0}"
if [[ -z "$TAG" ]]; then
read -r -p "Enter image tag (example: 200-develop): " TAG
fi
if [[ -z "$TAG" ]]; then
echo "Tag is required." >&2
exit 1
fi
if [[ "$DOCKERFILE" != /* ]]; then
DOCKERFILE="$ROOT_DIR/$DOCKERFILE"
fi