Skip to content

Commit 800e217

Browse files
committed
Add a script to generate the config file for adoptopenjdk official docker
images at DockerHub.
1 parent ba8e2ff commit 800e217

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

dockerhub_config_update.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# Script that generates the `adoptopenjdk` config file for the official docker
16+
# image github repo.
17+
# Process to update the official docker image repo
18+
# 1. Run ./update_all.sh to update all the dockerfiles in the current repo.
19+
# 2. Submit PR to push the newly generated dockerfiles to the current repo.
20+
# 3. After above PR is merged, git pull the latest changes.
21+
# 4. Run this command
22+
#
23+
set -o pipefail
24+
25+
source ./common_functions.sh
26+
27+
latest_version="12"
28+
hotspot_latest_tags="hotspot, latest"
29+
openj9_latest_tags="openj9"
30+
31+
# Get the latest git commit of the current repo.
32+
# This is assumed to have all the latest dockerfiles already.
33+
gitcommit=$(git log | head -1 | awk '{ print $2 }')
34+
35+
echo "# AdoptOpenJDK official images for OpenJDK with HotSpot and OpenJDK with Eclipse OpenJ9."
36+
echo
37+
echo "Maintainers: Dinakar Guniguntala <[email protected]> (@dinogun)"
38+
echo "GitRepo: https://github.com/AdoptOpenJDK/openjdk-docker.git"
39+
40+
# Iterate through all the VMs, for each supported version and packages to
41+
# generate the config file.
42+
for vm in ${all_jvms}
43+
do
44+
for ver in ${supported_versions}
45+
do
46+
echo
47+
echo "#------------------------------${vm} v${ver} images-------------------------------"
48+
for pkg in ${all_packages}
49+
do
50+
echo
51+
# Iterate through each of the Dockerfiles.
52+
for file in $(find . -name "Dockerfile.*" | grep "/${ver}" | grep "${vm}" | grep "${pkg}")
53+
do
54+
# file will look like ./12/jdk/debian/Dockerfile.openj9.nightly.slim
55+
# dockerfile name
56+
dfname=$(basename ${file})
57+
# dockerfile dir
58+
dfdir=$(dirname ${file} | cut -c 3-)
59+
os=$(echo ${file} | awk -F '/' '{ print $4 }')
60+
# build = release or nightly
61+
build=$(echo ${dfname} | awk -F "." '{ print $3 }')
62+
# btype = full or slim
63+
btype=$(echo ${dfname} | awk -F "." '{ print $4 }')
64+
65+
# Currently we are not pushing docker images for Alpine, Debian and Windows
66+
if [ "${os}" == "windows" -o "${os}" == "alpine" -o "${os}" == "debian" ]; then
67+
continue;
68+
fi
69+
70+
# We do not push our nightly and slim images either.
71+
if [ "${build}" == "nightly" -o "${btype}" == "slim" ]; then
72+
continue;
73+
fi
74+
75+
# Generate the tags
76+
full_version=$(grep "VERSION" ${file} | awk '{ print $3 }')
77+
ojdk_version=$(echo ${full_version} | sed 's/\(jdk\|jdk-\)//' | awk -F '_' '{ print $1 }')
78+
ojdk_version=$(echo ${ojdk_version} | sed 's/+/_/')
79+
80+
full_ver_tag="${ojdk_version}-${pkg}"
81+
# Add the openj9 version
82+
if [ "${vm}" == "openj9" ]; then
83+
openj9_version=$(echo ${full_version} | awk -F '_' '{ print $2 }')
84+
full_ver_tag="${full_ver_tag}-${openj9_version}"
85+
else
86+
full_ver_tag="${full_ver_tag}-${vm}"
87+
fi
88+
ver_tag="${ver}-${pkg}-${vm}"
89+
all_tags="${full_ver_tag}, ${ver_tag}"
90+
if [ "${pkg}" == "jdk" ]; then
91+
jdk_tag="${ver}-${vm}"
92+
all_tags="${all_tags}, ${jdk_tag}"
93+
# Add the "latest", "hotspot" and "openj9" tags for the right version
94+
if [ "${ver}" == "${latest_version}" ]; then
95+
vm_tags="${vm}_latest_tags"
96+
eval vm_tags_val=\${$vm_tags}
97+
all_tags="${all_tags}, ${vm_tags_val}"
98+
fi
99+
fi
100+
101+
# Generate the supported arches for the above tags.
102+
arches=$(echo $(grep ') \\' ${file} | \
103+
sed 's/\(ppc64el\|x86_64\|aarch64\)//g' | \
104+
sed 's/armhf/arm32v7/' | \
105+
sed 's/arm64/arm64v8/' | \
106+
sort | grep -v "*" | \
107+
sed 's/) \\//g; s/|/ /g'))
108+
arches=$(echo ${arches} | sed 's/ /, /g')
109+
110+
# Print them all
111+
echo "Tags: ${all_tags}"
112+
echo "Architectures: ${arches}"
113+
echo "GitCommit: ${gitcommit}"
114+
echo "Directory: ${dfdir}"
115+
echo "File: ${dfname}"
116+
done
117+
done
118+
done
119+
done

0 commit comments

Comments
 (0)