Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tomee Architectures based on openjdk base image Architectures #3398

Merged
merged 1 commit into from
Sep 6, 2017

Conversation

tianon
Copy link
Member

@tianon tianon commented Aug 31, 2017

cc @lordofthejars @otaviojava -- does this seem sane to you? I've personally tested this on s390x (and successfully run at least tomee:7-jre-1.7.4-webprofile), and it seems like tomee's upstream tarballs really should "just work" anywhere openjdk does.

See https://github.com/docker-library/official-images#architectures-other-than-amd64, https://github.com/docker-library/official-images#multiple-architectures, and #2289 for more details about multiarch + official images. 👍

I've also got a script which generates this file now, but it depends on having the bashbrew tool installed locally to scrape the architectures of openjdk: (run from a checkout of the tomee repo)

#!/usr/bin/env bash
set -Eeuo pipefail

self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

versions=( */ )
versions=( "${versions[@]%/}" )

latest="$(echo "${versions[*]}" | xargs -n1 | grep -- '-webprofile$' | sort -V | tail -1)"
declare -A aliases=(
	["$latest"]='latest'
)

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

	eval "declare -g -A 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 'tomee'

declare -A versionArches=() popularArches=()
mostPopularArches=
mostPopularArchesN=0

for version in "${versions[@]}"; do
	parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
	arches="${parentRepoToArches[$parent]}"

	versionArches["$version"]="$arches"

	n="${popularArches["$arches"]:-0}"
	(( n++ )) || :
	popularArches["$arches"]="$n"

	if [ "$n" -gt "$mostPopularArchesN" ]; then
		mostPopularArches="$arches"
		mostPopularArchesN="$n"
	fi
done

# prints "$2$1$3$1...$N"
join() {
	local sep="$1"; shift
	local out; printf -v out "${sep//%/%%}%s" "$@"
	echo "${out#$sep}"
}

commit="$(git log -1 --format='format:%H' HEAD --)"
cat <<-EOH
Maintainers: Alex Soto <asotobu@gmail.com> (@lordofthejars),
             Otavio Santana <otaviojava@apache.org> (@otaviojava)
GitRepo: https://github.com/tomitribe/docker-tomee.git
GitCommit: $commit
Architectures: $(join ', ' $mostPopularArches)
EOH

for version in "${versions[@]}"; do
	arches="${versionArches[$version]}"

	echo
	echo "Tags: $(join ', ' $version ${aliases[$version]:-})"
	if [ "$arches" != "$mostPopularArches" ]; then
		echo "Architectures: $(join ', ' $arches)"
	fi
	echo "Directory: $version"
done

I'd be happy to send a PR of this script too if it's interesting, but I can also just save it to run again if it's ever needed. 😄

@otaviojava
Copy link
Contributor

@tianon that's fine thank you for this contribution.
Please, go a head.

@yosifkit yosifkit merged commit 8f4cece into docker-library:master Sep 6, 2017
@yosifkit yosifkit deleted the tomee-arches branch September 6, 2017 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants