Something went wrong. Try again.
A fast and easy to use app to manage a physical music collection
Something went wrong. Try again.
2.3 kB · 73 lines
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374#!/usr/bin/env bash
#MISE description="Validate that the Dockerfile builder image exists and supports required architectures"
set -e
source "$(git rev-parse --show-toplevel)/scripts/_helpers.sh"
ensure_working_directory!
required_archs=("amd64" "arm64")
# Parse Dockerfile ARGselixir_version=$(grep -E '^ARG ELIXIR_VERSION=' Dockerfile | sed 's/ARG ELIXIR_VERSION=//')otp_version=$(grep -E '^ARG OTP_VERSION=' Dockerfile | sed 's/ARG OTP_VERSION=//')debian_version=$(grep -E '^ARG DEBIAN_VERSION=' Dockerfile | sed 's/ARG DEBIAN_VERSION=//')
if [[ -z "$elixir_version" || -z "$otp_version" || -z "$debian_version" ]]; then echo "Error: could not parse all version ARGs from Dockerfile" exit 1fi
tag="${elixir_version}-erlang-${otp_version}-debian-${debian_version}"image="hexpm/elixir:${tag}"
debug_msg "Checking ${image}"
# Obtain anonymous auth tokentoken=$(curl -sf "https://auth.docker.io/token?service=registry.docker.io&scope=repository:hexpm/elixir:pull" | jq -r '.token')
if [[ -z "$token" || "$token" == "null" ]]; then echo "Error: failed to obtain Docker Hub auth token" exit 1fi
# Fetch manifest listhttp_code=$(curl -s -o /tmp/manifest.json -w '%{http_code}' \ -H "Authorization: Bearer ${token}" \ -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" \ "https://registry.hub.docker.com/v2/hexpm/elixir/manifests/${tag}")
if [[ "$http_code" != "200" ]]; then debug_msg "Error: image tag not found on Docker Hub (HTTP ${http_code})" rm -f /tmp/manifest.json exit 1fi
# Extract supported architectures for linux OSsupported_archs=$(jq -r '.manifests[]? | select(.platform.os == "linux") | .platform.architecture' /tmp/manifest.json)rm -f /tmp/manifest.json
if [[ -z "$supported_archs" ]]; then debug_msg "Error: no linux platform entries found in manifest" exit 1fi
all_valid=true
for arch in "${required_archs[@]}"; do if echo "$supported_archs" | grep -qx "$arch"; then debug_msg "linux/${arch} supported" else debug_msg "linux/${arch} NOT supported" all_valid=false fidone
if [[ "$all_valid" == true ]]; then debug_msg "Image is valid for all required architectures"else debug_msg "Error: image does not support all required architectures" exit 1fi