Skip to content

Commit

Permalink
Merge pull request #95 from infosiftr/multiarch
Browse files Browse the repository at this point in the history
Add explicit multiarch support in "generate-stackbrew-library.sh"
  • Loading branch information
yosifkit authored Jun 8, 2017
2 parents 4d181db + 016e0d7 commit 7b62250
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ dirCommit() {
)
}

getArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'

eval "declare -A -g parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
getArches 'redis'

cat <<-EOH
# this file is generated via https://github.com/docker-library/redis/blob/$(fileCommit "$self")/$self
Expand All @@ -59,9 +75,13 @@ for version in "${versions[@]}"; do
${aliases[$version]:-}
)

parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
arches="${parentRepoToArches[$parent]}"

echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
Architectures: $(join ', ' $arches)
GitCommit: $commit
Directory: $version
EOE
Expand All @@ -87,9 +107,19 @@ for version in "${versions[@]}"; do
variantAliases=( "${versionAliases[@]/%/-$variant}" )
variantAliases=( "${variantAliases[@]//latest-/}" )

case "$v" in
32bit) variantArches='amd64' ;;
windows/*) variantArches='windows-amd64' ;;
*)
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
variantArches="${parentRepoToArches[$variantParent]}"
;;
esac

echo
cat <<-EOE
Tags: $(join ', ' "${variantAliases[@]}")
Architectures: $(join ', ' $variantArches)
GitCommit: $commit
Directory: $dir
EOE
Expand Down

0 comments on commit 7b62250

Please sign in to comment.