Skip to content

Commit

Permalink
Update "tianon/gosu" Docker Hub image to build via bashbrew instead o…
Browse files Browse the repository at this point in the history
…f bespoke script

This gives us nice provenance, etc; see https://explore.ggcr.dev/?image=tianon/gosu:1.16
  • Loading branch information
tianon committed Nov 2, 2023
1 parent 99f2f75 commit d126529
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 96 deletions.
9 changes: 0 additions & 9 deletions hub/alpine.yml

This file was deleted.

66 changes: 0 additions & 66 deletions hub/build.sh

This file was deleted.

10 changes: 0 additions & 10 deletions hub/debian.yml

This file was deleted.

54 changes: 54 additions & 0 deletions hub/gsl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -Eeuo pipefail

preferredOrder=( alpine debian )

dir="$(dirname "$BASH_SOURCE")"
cd "$dir"

commit="$(git log -1 --format='format:%H' HEAD -- .)"
cat <<-EOH
Maintainers: Tianon Gravi <[email protected]> (@tianon)
GitRepo: https://github.com/tianon/gosu.git
GitCommit: $commit
Directory: hub
Builder: buildkit
EOH

version=
i=0; jq=; froms=()
for variant in "${preferredOrder[@]}"; do
from="$(awk 'toupper($1) == "FROM" { print $2; exit }' "Dockerfile.$variant")" # TODO multi-stage?
variantVersion="$(awk 'toupper($1) == "ENV" && toupper($2) == "GOSU_VERSION" { print $3; exit }' "Dockerfile.$variant")"
version="${version:-$variantVersion}"
if [ "$version" != "$variantVersion" ]; then
echo >&2 "error: mismatched version in '$variant' ('$version' vs '$variantVersion')"
exit 1
fi
jq="${jq:+$jq, }$variant: (.[$i].arches | keys_unsorted)"
froms["$i"]="$from"
(( i++ )) || :
done
arches="$(bashbrew remote arches --json "${froms[@]}" | jq -sc "{ $jq }")" # { alpine: [ "amd64", ... ], debian: [ "amd64", ... ] }

queue="$(jq <<<"$arches" -r 'to_entries | map(@sh "variant=\(.key)\narch=\(.value[])") | map(@sh) | join("\n")')"
eval "queue=( $queue )"

declare -A seenArches=()
for item in "${queue[@]}"; do
eval "$item" # variant=yyy arch=xxx
[ -n "$variant" ]
[ -n "$arch" ]
tags="$variant-$arch"
sharedTags="$variant, $version-$variant"
if [ -z "${seenArches["$arch"]:-}" ]; then
tags+=", $arch"
sharedTags+=", $version, latest"
fi
echo
echo "Tags: $tags"
[ -z "$sharedTags" ] || echo "SharedTags: $sharedTags"
echo "Architectures: $arch"
echo "File: Dockerfile.$variant"
: "${seenArches["$arch"]:=1}"
done
11 changes: 0 additions & 11 deletions hub/latest.yml

This file was deleted.

0 comments on commit d126529

Please sign in to comment.