Files
minideb/pushmanifest
T
Carlos Rodriguez Hernandez f864c9f5cb Don't build/publish minideb in GCR
Signed-off-by: Carlos Rodriguez Hernandez <carlosrh@vmware.com>
2022-06-29 21:20:45 +00:00

75 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -e
set -u
set -o pipefail
DISTS=${DISTS:-"buster
bullseye
latest
"}
DISTS_WITH_SNAPSHOT=${DISTS_WITH_SNAPSHOT:-buster}
BASENAME=bitnami/minideb
PLATFORMS=${PLATFORMS:-amd64 arm64}
DRY_RUN=${DRY_RUN:-}
SNAPSHOT_ID=${SNAPSHOT_ID:-}
read -r -a ARCHS <<<"$PLATFORMS"
run_docker() {
if [[ -n "${DRY_RUN:-}" ]]; then
echo "DRY RUN docker ${*}"
else
docker "$@"
fi
}
list_includes() {
local list=""
local element=""
list=${1?You must provide a list}
element=${2:?You must provide an element}
for candidate in $list; do
if [[ "$candidate" == "$element" ]]; then
true
return
fi
done
false
return
}
if [ -n "${DOCKER_PASSWORD:-}" ]; then
echo "$DOCKER_PASSWORD" | run_docker login -u "$DOCKER_USERNAME" --password-stdin
fi
push_manifest() {
local image=""
local archs=""
image="${1:?You must provide the image base to publish}"
archs=("${@:2}")
local arch_images=()
for arch in "${archs[@]}"; do
arch_images+=("$image-$arch")
done
run_docker manifest create "$image" "${arch_images[@]}"
run_docker manifest push "$image"
}
tags=()
for DIST in $DISTS; do
tags+=("$DIST")
if list_includes "$DISTS_WITH_SNAPSHOT" "$DIST" ; then
tags+=("$DIST-snapshot-${SNAPSHOT_ID:-$(./snapshot_id)}")
fi
done
repositories=("$BASENAME")
for tag in "${tags[@]}"; do
for repo in "${repositories[@]}"; do
push_manifest "$repo:$tag" "${ARCHS[@]}"
done
done