Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions scripts/check-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -euo pipefail
#set -x

REGISTRY_URL="docker-registry.nginx.com/nginx"
IMAGE_NAME=${1:-""}

search=${2:-""}

usage() {
echo "Usage: $0 <image-name> [search-pattern]"
echo "Example: $0 agentv3 alpine"
exit 1
}

if [[ -z "${IMAGE_NAME}" ]]; then
usage
fi

echo "Checking images in ${REGISTRY_URL}/${IMAGE_NAME}"

# Fetch all tags from the remote registry
skopeo list-tags docker://${REGISTRY_URL}/${IMAGE_NAME} | jq -r '.Tags[]' > all_tags.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use the skopeo docker image instead? https://github.com/containers/skopeo/blob/main/install.md#container-images

Would save people having to install skopeo on their machines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True yeah I'll add that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this implemented as a Github workflow in that case?

echo $(wc -l < all_tags.txt) "tags fetched."

# Filter out tags that end with three or more digits (nightly/build tags)
grep -Ev '\d{3,}$' all_tags.txt | sort -u > filtered_tags.txt
echo $(wc -l < filtered_tags.txt) "tags after filtering."

FOUND=($(grep -E "${search}" filtered_tags.txt | sort)) || { echo "No tags found matching '${search}'"; exit 1; }
echo "tags matching '${search}':" ${#FOUND[@]}

for tag in "${FOUND[@]}"; do
echo ":: ${REGISTRY_URL}/${IMAGE_NAME}:$tag"
podman pull ${REGISTRY_URL}/${IMAGE_NAME}:$tag > /dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a check to see if docker or podman is installed? Some people might use docker over podman

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

podman run ${REGISTRY_URL}/${IMAGE_NAME}:$tag nginx -v
podman run ${REGISTRY_URL}/${IMAGE_NAME}:$tag nginx-agent --version
podman rm -f $(podman ps -a -q) > /dev/null 2>&1 || true
done

Loading