-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathwait_for_images_ghcr.sh
More file actions
executable file
·71 lines (60 loc) · 2.14 KB
/
wait_for_images_ghcr.sh
File metadata and controls
executable file
·71 lines (60 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
set -euo pipefail
# Prerequisite checks
if ! command -v jq >/dev/null 2>&1; then
echo "Error: jq is required but not installed or not in PATH." >&2
exit 2
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Error: docker is required but not installed or not in PATH." >&2
exit 2
fi
if ! docker buildx version >/dev/null 2>&1; then
echo "Error: docker buildx is required but not available. Ensure Docker Buildx is installed and working." >&2
exit 2
fi
IMAGE_NAME="${1:?Error: IMAGE_NAME required}"
IMAGE_TAG="${2:?Error: IMAGE_TAG required}"
ARCHES="${3:-amd64,arm64}"
TIMEOUT="${4:-300}"
DELAY="${5:-15}"
# If IMAGE_NAME contains a slash, treat as fully-qualified; else, prefix with default registry/namespace
REGISTRY="ghcr.io"
NAMESPACE="feldera"
if [[ "$IMAGE_NAME" == */* ]]; then
FULL_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
else
FULL_IMAGE="${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG}"
fi
IFS=',' read -ra ARCH_ARRAY <<< "$ARCHES"
echo "Waiting for arches ${ARCH_ARRAY[*]} in ${FULL_IMAGE}..."
start_time=$(date +%s)
while [ $(( $(date +%s) - start_time )) -lt "$TIMEOUT" ]; do
all_ready=true
if RESULT=$(docker buildx imagetools inspect "$FULL_IMAGE" --format '{{json .}}'); then
if [ -z "$RESULT" ]; then
echo "❌ Image not found: $FULL_IMAGE (empty)"
sleep $DELAY
continue
fi
else
echo "❌ Image not found: $FULL_IMAGE (inspect failed)"
sleep $DELAY
continue
fi
ARCHES_READY=true
for ARCH in "${ARCH_ARRAY[@]}"; do
if echo "$RESULT" | jq -e --arg arch "$ARCH" \
'.manifest.manifests[]? | select(.platform.architecture == $arch and .platform.os == "linux")'; then
echo " ✅ ${IMAGE_NAME} $ARCH"
else
echo " ❌ Missing ${IMAGE_NAME} $ARCH"
ARCHES_READY=false
fi
done
[ "$ARCHES_READY" = true ] && echo "✅ ${IMAGE_NAME}" || { echo "⏳ ${IMAGE_NAME}"; all_ready=false; }
echo ""
[ "$all_ready" = true ] && echo "🎉 All ready!" && exit 0
sleep $DELAY
done
echo "💥 Timeout after ${TIMEOUT}s" && exit 1