-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-docker-sha256
executable file
·25 lines (22 loc) · 1.13 KB
/
update-docker-sha256
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
#
# This script can be used to update SHA256 references in a docker-compose file
# Changes will then need to be pushed to GitHub to be effective.
# Debian Buster 10.11 is the latest to have the ppc64le architecture
declare -a OSimages=("d11:latest" "d12:latest" "u20:latest" "u22:latest" "u24:latest")
export REGISTRY="ghcr.io/perfsonar/unibuild/"
COMPOSE=docker-compose-unibuild.yml
for OSimage in ${OSimages[@]}; do
export OSimage
echo $OSimage
for LINE in `(docker buildx imagetools inspect "${REGISTRY}${OSimage}"; echo) | perl -nle '$sha=$1 if /$ENV{OSimage}\@sha256:([a-z0-9]*)/; print "$1:$sha" if /(linux\/(amd64|arm64|arm\/v7|ppc64le))/;'`; do
arch=${LINE%:*}
arch="${arch//\//\\/}"
sha=${LINE#*:}
echo "New image: $LINE"
export arch sha
perl -nli -e 'if (/platform: /) {$sha = ""}; if (/platform: \"$ENV{arch}\"/) {$sha = $ENV{sha}}; if (/$ENV{REGISTRY}$ENV{OSimage}\@sha256.*/ && $sha ne "") {print " image: $ENV{REGISTRY}$ENV{OSimage}\@sha256:$sha"} else {print}' $COMPOSE
done
echo
done
#git commit -m "Updating Docker multiarch image sha256" $COMPOSE