pomerium/scripts/check-docker-images
2024-01-11 13:49:30 -07:00

24 lines
769 B
Bash
Executable file

#!/usr/bin/bash
set -euo pipefail
_project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/.."
for _f in $(find "$_project_root" -name "*Dockerfile*"); do
for _img in $(sed -n -r -e 's/^FROM ([^:]*)(:[^@]*)(@sha256[^ ]*) as .*$/\1\2\3/p' "$_f"); do
_media_type="$(
docker buildx imagetools inspect \
--format='{{print .Manifest.MediaType }}' \
"$_img"
)"
if [[ "$_media_type" != "application/vnd.oci.image.index.v1+json" && "$_media_type" != "application/vnd.docker.distribution.manifest.list.v2+json" ]]; then
echo "in
file=$_f
image=$_img
media_type=$_media_type
docker FROM image is not a multi-platform manifest
"
exit 1
fi
done
done