Updated script
This commit is contained in:
@@ -17,6 +17,7 @@ Options:
|
|||||||
--component <value> Optional. Service name OR build context path under app.
|
--component <value> Optional. Service name OR build context path under app.
|
||||||
If omitted, build all services with build contexts.
|
If omitted, build all services with build contexts.
|
||||||
--repo <namespace> Docker namespace/org (default: joafri)
|
--repo <namespace> Docker namespace/org (default: joafri)
|
||||||
|
--skip-non-buildable Exit 0 (with warning) when app has no services with build context
|
||||||
--no-push Build only, no push or manifest creation
|
--no-push Build only, no push or manifest creation
|
||||||
-h, --help Show this help
|
-h, --help Show this help
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ component=""
|
|||||||
tag=""
|
tag=""
|
||||||
repo_ns="$default_repo"
|
repo_ns="$default_repo"
|
||||||
push_image=1
|
push_image=1
|
||||||
|
skip_non_buildable=0
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -61,6 +63,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
push_image=0
|
push_image=0
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--skip-non-buildable)
|
||||||
|
skip_non_buildable=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
@@ -162,6 +168,10 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
if [[ -z "${AppID:-}" ]]; then
|
||||||
|
export AppID="$app_id"
|
||||||
|
fi
|
||||||
|
|
||||||
docker compose -f "$compose_file" config --format json > "$compose_json"
|
docker compose -f "$compose_file" config --format json > "$compose_json"
|
||||||
|
|
||||||
mapfile -t all_services < <(
|
mapfile -t all_services < <(
|
||||||
@@ -169,7 +179,12 @@ mapfile -t all_services < <(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if [[ ${#all_services[@]} -eq 0 ]]; then
|
if [[ ${#all_services[@]} -eq 0 ]]; then
|
||||||
|
if [[ "$skip_non_buildable" -eq 1 ]]; then
|
||||||
|
echo "WARN: no buildable services found in $compose_file (skipped)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
echo "ERROR: no buildable services found in $compose_file" >&2
|
echo "ERROR: no buildable services found in $compose_file" >&2
|
||||||
|
echo "Hint: pass --skip-non-buildable for batch loops over mixed app types." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user