diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..076746a9c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Jinja CI +on: + pull_request: + paths: + - generate_dockerfiles.py + - test_generate_dockerfiles.py + branches: [ main ] + +permissions: + contents: read + +jobs: + CI: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: "3.x" + + - name: Install dependencies + run: "pip3 install -r requirements.txt" + + - name: Run tests + run: "python3 test_generate_dockerfiles.py" diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index bbca34a03..168f313bd 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -14,4 +14,4 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Run Sanity Check Script - run: " bash sanity.sh" + run: "bash sanity.sh" diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index ebbb8ca89..f26162ca0 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -17,8 +17,15 @@ jobs: with: persist-credentials: false + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: "3.x" + + - name: Install dependencies + run: "pip3 install -r requirements.txt" + - name: Run updater - run: " bash update_all.sh" + run: "python3 generate_dockerfiles.py" - uses: gr2m/create-or-update-pull-request-action@dc1726cbf4dd3ce766af4ec29cfb660e0125e8ee # v1 env: diff --git a/.gitignore b/.gitignore index a30cba8d4..47c207ac5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ official-eclipse-temurin *hotspot.txt library/ .vscode/ + __pycache__/ diff --git a/README.md b/README.md index bbc7a09c0..8274c5c2d 100644 --- a/README.md +++ b/README.md @@ -24,19 +24,15 @@ This section is for maintainers of the containers repository. ### Hourly automated Job A [Updater GitHub Action](.github/workflows/updater.yml) runs every 30 mins which triggers the -[`./update_all.sh`](./update_all.sh) script to update the Dockerfiles by creating a Pull Request containing any changes. +[`./generate_dockerfiles.py`](./generate_dockerfiles.py) script to update the Dockerfiles by creating a Pull Request containing any changes. -#### update_all.sh +#### generate_dockerfiles.py [`./update_all.sh`](./update_all.sh) is a wrapper script to control what is passed into [`./update_multiarch.sh`](./update_multiarch.sh). -#### update_multiarch.sh - -[`./update_multiarch.sh`](./update_multiarch.sh) loops around the configuration for which versions and architectures are supported in [`./common_functions.sh`](./common_functions.sh) and uses a bunch of small functions in [`./dockerfile_functions.sh`](./dockerfile_functions.sh) to write the Dockerfiles. - ### Manual Release -During a release you can also run [`./update_all.sh`](./update_all.sh) manually by heading to The [GitHub Action definition](https://github.com/adoptium/containers/actions/workflows/updater.yml) and clicking the **Run Workflow** button and making sure the `main` (default) branch is selected, then click the next **Run Workflow** button. +During a release you can also run [`./generate_dockerfiles.py`](./generate_dockerfiles.py) manually by heading to The [GitHub Action definition](https://github.com/adoptium/containers/actions/workflows/updater.yml) and clicking the **Run Workflow** button and making sure the `main` (default) branch is selected, then click the next **Run Workflow** button. ### Review and Merge PR diff --git a/common_functions.sh b/common_functions.sh deleted file mode 100755 index bff92c157..000000000 --- a/common_functions.sh +++ /dev/null @@ -1,632 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Config files -tags_config_file="config/tags.config" -# shellcheck disable=SC2034 -hotspot_config_file="config/hotspot.config" - -# Test lists -# shellcheck disable=SC2034 -test_image_types_file="config/test_image_types.list" -# shellcheck disable=SC2034 -test_image_types_all_file="config/test_image_types_all.list" -# shellcheck disable=SC2034 -test_buckets_file="config/test_buckets.list" - -# All supported JVMs -# shellcheck disable=SC2034 # used externally -all_jvms="hotspot" - -# Supported arches for each of the os_families -os_families="linux alpine-linux windows" -linux_arches="aarch64 armv7l ppc64le s390x x86_64" -alpine_linux_arches="aarch64 x86_64" -windows_arches="windows-amd windows-nano" - -# All supported packages -# shellcheck disable=SC2034 # used externally -all_packages="jdk jre" - -# All supported runtypes -# shellcheck disable=SC2034 # used externally -all_runtypes="build test" - -# Setting the OS's built in test -PR_TEST_OSES="ubuntu" - -# `runtype` specifies the reason for running the script, i.e for building images or to test for a PR check -# Supported values for runtype : "build", "test" -# setting default runtype to build (can be changed via `set_runtype` function) -runtype="build" - -# Current JVM versions supported -export supported_versions="8 11 17 21" -export latest_version="21" - -# Current builds supported -export supported_builds="releases" - -function check_version() { - local version=$1 - case ${version} in - 8|11|17|21) - ;; - *) - echo "ERROR: Invalid version" - ;; - esac -} - -# Set a valid version -function set_version() { - version=$1 - if [ -n "$(check_version "${version}")" ]; then - echo "ERROR: Invalid Version: ${version}" - echo "Usage: $0 [${supported_versions}]" - exit 1 - fi -} - -# Set runtype -function set_runtype() { - runtype=$1 - if [ "${runtype}" != "build" ] && [ "${runtype}" != "test" ]; then - echo "ERROR: Invalid RunType : ${runtype}" - echo "Supported Runtypes : ${all_runtypes}" - exit 1 - fi -} - -# Set the valid OSes for the current architecure. -function set_arch_os() { - if [ ! -z "$TARGET_ARCHITECTURE" ]; then - # Use buildx environment for build https://www.docker.com/blog/multi-platform-docker-builds/ - echo "overiding machine to $TARGET_ARCHITECTURE" - machine="$TARGET_ARCHITECTURE" - else - machine=$(uname -m) - fi - case ${machine} in - armv7l|linux/arm/v7) - current_arch="armv7l" - oses="centos focal jammy ubi9-minimal" - os_family="linux" - ;; - aarch64|arm64) - current_arch="aarch64" - oses="centos focal jammy ubi9-minimal" - os_family="linux" - ;; - ppc64el|ppc64le) - current_arch="ppc64le" - oses="centos focal jammy ubi9-minimal" - os_family="linux" - ;; - s390x) - current_arch="s390x" - oses="clefos focal jammy ubi9-minimal" - os_family="linux" - ;; - amd64|x86_64) - case $(uname) in - MINGW64*|MSYS_NT*) - current_arch="x86_64" - # this variable will only be set when running under GitHub Actions - if [ -n "${BUILD_OS}" ]; then - case ${BUILD_OS} in - windows-2022) - oses="windowsservercore-ltsc2022 nanoserver-ltsc2022" - ;; - windows-2019) - oses="windowsservercore-1809 nanoserver-1809 windowsservercore-ltsc2019" - ;; - esac - fi - os_family="windows" - ;; - *) - # shellcheck disable=SC2034 # used externally - current_arch="x86_64" - # shellcheck disable=SC2034 # used externally - oses="alpine centos focal jammy ubi9-minimal" - # shellcheck disable=SC2034 # used externally - os_family="alpine-linux linux" - ;; - esac - ;; - *) - echo "ERROR: Unsupported arch:${machine}, Exiting" - exit 1 - ;; - esac -} - -# get shasums for a given architecture and os_family -# This is based on the hotspot_shasums_latest.sh -# arch = aarch64, armv7l, ppc64le, s390x, x86_64 -# os_family = linux, windows -function get_shasum() { - local arch=$2; - local os_family=$3; - - if ! declare -p "$1" >/dev/null 2>/dev/null; then - return; - fi - # shellcheck disable=SC2154,SC1083 - local shasum=$(sarray=$1[${os_family}_${arch}]; eval esum=\${"$sarray"}; echo "${esum}"); - echo "${shasum}" -} - -# Get the supported architectures for a given VM (Hotspot). -# This is based on the hotspot_shasums_latest.sh -function get_arches() { - # Check if the array has been defined. Array might be undefined if the - # corresponding build combination does not exist. - if ! declare -p "$1" >/dev/null 2>/dev/null; then - return; - fi - local archsums="$(declare -p "$1")"; - eval "declare -A sums=""${archsums#*=}"; - local arch="" - for arch in "${!sums[@]}"; - do - if [[ "${arch}" == version* ]] ; then - continue; - fi - # Arch is supported only if the shasum is not empty ! - # alpine-linux is for musl based images - # shellcheck disable=SC2154,SC1083 - local shasum=$(sarray=$1[${arch}]; eval esum=\${"$sarray"}; echo "${esum}"); - if [ -n "${shasum}" ]; then - local arch_val=$(echo ${arch} | sed 's/alpine-linux_//; s/linux_//; s/windows_//') - echo "${arch_val} " - fi - done -} - -# Check if the given VM is supported on the current architecture. -# This is based on the hotspot_shasums_latest.sh -function vm_supported_onarch() { - local vm=$1 - local sums=$2 - - if [ -n "$3" ]; then - test_arch=$3; - else - test_arch=$(uname -m) - fi - - case $test_arch in - arm64) test_arch="aarch64" ;; - esac - - local suparches=$(get_arches "${sums}") - local sup=$(echo "${suparches}" | grep "${test_arch}") - echo "${sup}" -} - -function cleanup_images() { - # Delete any old containers that have exited. - docker rm "$(docker ps -a | grep -e 'Exited' | awk '{ print $1 }')" 2>/dev/null - docker container prune -f 2>/dev/null - - # Delete any old images for our target_repo on localhost. - for image in $(docker images | grep -e 'adoptopenjdk' | awk -v OFS=':' '{ print $1, $2 }'); - do - docker rmi -f "${image}"; - done - - # Remove any dangling images - docker image prune -f 2>/dev/null -} - -function cleanup_manifest() { - # Remove any previously created manifest lists. - # Currently there is no way to do this using the tool. - rm -rf ~/.docker/manifests -} - -# Check if a given docker image exists on the server. -# This script errors out if the image does not exist. -function check_image() { - local img=$1 - - docker pull "${img}" >/dev/null - ret=$? - echo ${ret} -} - -# Parse hotspot.config file for an entry as specified by $4 -# $1 = VM -# $2 = Version -# $3 = Package -# $4 = OS -# $5 = String to look for. -function parse_vm_entry() { - local vm=$1; - local ver=$2; - local pkg=$3; - local os=$4; - entry=$( < config/"$vm".config grep -B 4 -E "[[:space:]]$ver\/$pkg\/$os$|[[:space:]]$ver\/$pkg\/windows\/$os$|[[:space:]]$ver\/$pkg\/ubuntu\/$os$|[[:space:]]$ver\/$pkg\/ubi\/$os$" | grep "$5" | sed "s/$5 //") - echo "${entry}" -} - -# Parse the hotspot.config file for the supported OSes -# $1 = VM -function parse_os_entry() { - entry=$( < config/"$1".config grep "^OS:" | sed "s/OS: //") - echo "${entry}" -} - -# Read the tags file and parse the specific tag. -# $1 = OS -# $2 = Package -# $3 = Build (releases / nightly) -# $4 = Type (full / slim) -function parse_tag_entry() { - tag="$1-$2-$3-$4-tags:" - entry=$( < "${tags_config_file}" grep "${tag}" | sed "s/${tag} //") - echo "${entry}" -} - -# Where is the manifest tool installed?" -# Manifest tool (docker with manifest support) needs to be added from here -# https://github.com/clnperez/cli -# $ cd /opt/manifest_tool -# $ git clone -b manifest-cmd https://github.com/clnperez/cli.git -# $ cd cli -# $ make -f docker.Makefile cross -manifest_tool_dir="/opt/manifest_tool" -manifest_tool=${manifest_tool_dir}/cli/build/docker - -function check_manifest_tool() { - if docker manifest 2>/dev/null; then - echo "INFO: Docker manifest found at $(command -v docker)" - manifest_tool=$(command -v docker) - else - if [ ! -f "${manifest_tool}" ]; then - echo - echo "ERROR: Docker with manifest support not found at path ${manifest_tool}" - exit 1 - fi - fi -} - -# Build valid image tags using the tags.config file as the base -function build_tags() { - local vm=$1; shift - local ver=$1; shift; - local pkg=$1; shift; - local rel=$1; shift; - local os=$1; shift; - local build=$1; shift; - local rawtags=$* - local tmpfile=raw_arch_tags.$$.tmp - - # For jre builds, replace the version tag to distinguish it from the jdk - if [ "${pkg}" == "jre" ]; then - rel="${rel//jdk/jre}" - fi - # Get the list of supported arches for this vm / ver /os combo - local arches=$(parse_vm_entry "${vm}" "${ver}" "${pkg}" "${os}" "Architectures:") - # Replace the proper version string in the tags - local rtags=$(echo "${rawtags}" | sed "s/{{ JDK_${build}_VER }}/${rel}/gI; s/{{ OS }}/${os}/gI;"); - echo "${rtags}" | sed "s/{{ *ARCH *}}/{{ARCH}}/" | - # Separate the arch and the generic alias tags - awk '{ a=0; n=0; - for (i=1; i<=NF; i++) { - if (match($i, "ARCH") > 0) { - atags[a++]=sprintf(" %s", $i); - } else { - natags[n++]=sprintf(" %s", $i); - } - } - } END { - printf("arch_tags: "); for (key in atags) { printf"%s ", atags[key] }; printf"\n"; - printf("tag_aliases: "); for (key in natags) { printf"%s ", natags[key] }; printf"\n"; - }' > ${tmpfile} - - # shellcheck disable=SC2034 # used externally - # tag_aliases is a global variable, used for generating manifest list - tag_aliases=$( < "${tmpfile}" grep "^tag_aliases:" | sed "s/tag_aliases: //") - local raw_arch_tags=$( < "${tmpfile}" grep "^arch_tags:" | sed "s/arch_tags: //") - # arch_tags is a global variable - arch_tags="" - # Iterate through the arch tags and expand to add the supported arches. - local tag="" - local arch="" - for tag in ${raw_arch_tags} - do - for arch in ${arches} - do - windows_pat="windows.*" - if [[ "$arch" =~ ${windows_pat} ]]; then - arch="x86_64" - fi - # Check if all the supported arches are available for this build. - # shellcheck disable=SC2154 #declared externally - supported=$(vm_supported_onarch "${vm}" "${shasums}" "${arch}") - if [ -z "${supported}" ]; then - continue; - fi - # shellcheck disable=SC2001 - atag=$(echo "${tag}" | sed "s/{{ARCH}}/${arch}"/g) - arch_tags="${arch_tags} ${atag}" - done - done - rm -f ${tmpfile} -} - -# Build the URL using adoptopenjdk.net v3 api based on the given parameters -# request_type = feature_releases -# release_type = ga / ea -# url_impl = hotspot -# url_arch = aarch64 / ppc64le / s390x / x64 -# url_pkg = jdk / jre -# url_os_family = linux / windows -function get_v3_url() { - local request_type=$1 - local release_type=$2 - local url_impl=$3 - local url_pkg=$4 - local url_arch=$5 - local url_os_family=$6 - local url_heapsize="normal" - - if [ "${release_type}" == "releases" ]; then - rel_type="ga" - else - rel_type="ea" - fi - baseurl="https://api.adoptium.net/v3/assets/${request_type}/${version}/${rel_type}" - specifiers="page=0&page_size=1&sort_order=DESC&vendor=adoptium" - specifiers="${specifiers}&jvm_impl=${url_impl}&image_type=${url_pkg}&heap_size=${url_heapsize}" - windows_pat="windows.*" - if [ -n "${url_arch}" ]; then - if [[ "${url_arch}" =~ ${windows_pat} ]]; then - specifiers="${specifiers}&architecture=x64&os=windows" - else - specifiers="${specifiers}&architecture=${url_arch}" - if [ -n "${url_os_family}" ]; then - specifiers="${specifiers}&os=${url_os_family}" - else - specifiers="${specifiers}&os=linux" - fi - fi - else - specifiers="${specifiers}&os=linux" - fi - - echo "${baseurl}?${specifiers}" -} - -# Get the binary github link for a release given a V3 API URL -function get_v3_binary_url() { - local v3_url=$1 - local info_file=/tmp/info_$$.json - - if ! curl -Lso ${info_file} "${v3_url}" || [ ! -s ${info_file} ]; then - rm -f ${info_file} - return; - fi - python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['package']['link'])" < "${info_file}" - rm -f ${info_file} -} - -# Get the installer github link for a release given a V3 API URL -function get_v3_installer_url() { - local v3_url=$1 - local info_file=/tmp/info_$$.json - - if ! curl -Lso "${info_file}" "${v3_url}" || [ ! -s ${info_file} ]; then - rm -f ${info_file} - return; - fi - python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['installer']['link'])" < "${info_file}" - rm -f ${info_file} -} - -# Get the short build version from the full version for this specific arch -# $1 = full version -function get_nightly_short_version() { - local arch_build=$1 - local arch_full_version=$2 - - if [ "${arch_build}" = "nightly" ]; then - # Remove date and time at the end of full_version for nightly builds. - # Handle both the old and new date-time formats used by the Adopt build system. - # Older date-time format - 201809270034 - # shellcheck disable=SC2001 - arch_version=$(echo "${arch_full_version}" | sed 's/-[0-9]\{4\}[0-9]\{2\}[0-9]\{2\}[0-9]\{4\}$//') - # New date-time format - 2018-09-27-00-34 - # shellcheck disable=SC2001 - arch_version=$(echo "${arch_version}" | sed 's/-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}$//') - else - arch_version=${arch_full_version} - fi - echo "${arch_version}" -} - -# Get the shasums for the given specific build and arch combination. -function get_sums_for_build_arch() { - local ver=$1 - local vm=$2 - local pkg=$3 - local build=$4 - local arch=$5 - local os_family=$6 - - if [ -z ${os_family} ]; then - os_family=linux - fi - case ${arch} in - armv7l) - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" arm "${os_family}"); - ;; - aarch64) - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" aarch64 "${os_family}"); - ;; - ppc64le) - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" ppc64le "${os_family}"); - ;; - s390x) - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" s390x "${os_family}"); - ;; - x86_64) - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" x64 "${os_family}"); - ;; - windows-amd|windows-nano) - os_family=windows - LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" windows "${os_family}"); - ;; - *) - echo "Unsupported arch: ${arch}" - esac - - while : - do - shasum_file="${arch}_${build}_latest" - # Bad builds cause the latest url to return an empty file or sometimes curl fails - if ! curl -Lso "${shasum_file}" "${LATEST_URL}" || [ ! -s "${shasum_file}" ]; then - echo "Latest url not available at url: ${LATEST_URL}" - break; - fi - # Even if the file is not empty, it might just say "No matches" - availability=$(grep -e "No matches" -e "Not found" "${shasum_file}"); - # Print the arch and the corresponding shasums to the vm output file - if [ -z "${availability}" ]; then - # If there are multiple builds for a single version, then pick the latest one. - if [ "${arch}" == "windows-amd" ]; then - shasum=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['installer']['checksum'])" < "${shasum_file}") - else - shasum=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['package']['checksum'])" < "${shasum_file}") - fi - # Get the release version for this arch from the info file - arch_build_version=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['release_name'])" < "${shasum_file}") - # For nightly builds get the short version without the date/time stamp - arch_build_version=$(get_nightly_short_version "${build}" "${arch_build_version}") - # We compare the JDK version info separately from the VM type info because we may have dot releases - arch_build_base_version=$(echo "${arch_build_version}" | cut -d_ -f1) - arch_build_vm_type=$(echo "${arch_build_version}" | cut -s -d_ -f2) - full_version_base_version=$(echo "${full_version}" | cut -d_ -f1) - full_version_vm_type=$(echo "${full_version}" | cut -s -d_ -f2) - # If the latest for the current arch does not match with the latest for the parent arch, - # then skip this arch. - # Parent version in this case would be the "full_version" from function get_sums_for_build - # The parent version will automatically be the latest for all arches as returned by the v2 API - if [[ "${arch_build_base_version}" != "${full_version_base_version}"* || "${arch_build_vm_type}" != "${full_version_vm_type}" ]]; then - echo "Parent version not matching for arch ${arch}: ${arch_build_version}, ${full_version}" - # We only ship x64 for windows-amd so don't update the dockerfile if binary is unavailable - if [ "${arch}" != "windows-amd" ] && [ "${os_family}" != "alpine-linux" ]; then - break; - fi - fi - # Get the build date for this arch tarball - arch_last_build_date="$(curl -Lv "${shasums_url}" 2>&1 | grep "Last-Modified" | sed 's/< Last-Modified: //')" - # Convert to time since 1-1-1970 - arch_last_build_time="$(date --date "${arch_last_build_date}" +%s)" - # Only print the entry if the shasum is not empty - if [ -n "${shasum}" ]; then - printf "\t[version-%s]=\"%s\"\n" "${os_family}_${arch}" "${arch_build_version}" >> "${ofile_sums}" - printf "\t[version-%s]=\"%s\"\n" "${os_family}_${arch}" "${arch_build_version}" >> "${ofile_build_time}" - printf "\t[%s]=\"%s\"\n" "${os_family}_${arch}" "${shasum}" >> "${ofile_sums}" - printf "\t[%s]=\"%s\"\n" "${os_family}_${arch}" "${arch_last_build_time}" >> "${ofile_build_time}" - fi - fi - break; - done - rm -f "${shasum_file}" -} - -# Get shasums for the build and arch combination given -# If no arch given, generate for all valid arches -function get_sums_for_build() { - local ver=$1 - local vm=$2 - local pkg=$3 - local build=$4 - - info_url=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}"); - info=$(curl -Ls "${info_url}") - err=$(echo "${info}" | grep -e "Error" -e "No matches" -e "Not found") - if [ -n "${err}" ]; then - return; - fi - full_version=$(echo "${info}" | python3 -c "import sys, json; print(json.load(sys.stdin)[0]['release_name'])") - full_version=$(get_nightly_short_version "${build}" "${full_version}") - # Declare the array with the proper name for shasums and write to the vm output file. - printf "declare -A %s_%s_%s_%s_sums=(\n" "${pkg}" "${vm}" "${ver}" "${build}" >> "${ofile_sums}" - # We have another array for storing the last build time for each arch - printf "declare -A %s_%s_%s_%s_build_time=(\n" "${pkg}" "${vm}" "${ver}" "${build}" >> "${ofile_build_time}" - # Capture the full version according to adoptium - printf "\t[version]=\"%s\"\n" "${full_version}" >> "${ofile_sums}" - printf "\t[version]=\"%s\"\n" "${full_version}" >> "${ofile_build_time}" - # Need to get shasums for each of the OS Families - # families = alpine-linux, linux and windows - # alpine-linux is for musl based images - for os_fam in ${os_families} - do - # bash doesnt support '-' in the name of a variable - # So make alpine-linux as alpine_linux - local fam="${os_fam//-/_}" - local arches="${fam}_arches" - for arch in ${!arches} - do - get_sums_for_build_arch "${ver}" "${vm}" "${pkg}" "${build}" "${arch}" "${os_fam}" - done - done - printf ")\n" >> "${ofile_sums}" - printf ")\n" >> "${ofile_build_time}" - - echo - echo "sha256sums for the version ${full_version} for build type \"${build}\" is now available in ${ofile_sums}" - echo -} - -# get sha256sums for the specific builds and arches given. -# If no build or arch specified, do it for all valid ones. -function get_shasums() { - local ver=$1 - local vm=$2 - local pkg=$3 - local build=$4 - local ofile_sums="${vm}_shasums_latest.sh" - local ofile_build_time="${vm}_build_time_latest.sh" - - # Dont build the shasums array it already exists for the Ver/VM/Pkg/Build combination - if [ -f "${ofile_sums}" ]; then - # shellcheck disable=SC1090 - source ./"${vm}"_shasums_latest.sh - local sums="${pkg}_${vm}_${ver}_${build}_sums" - # File exists, which means shasums for the VM exists. - # Now check for the specific Ver/VM/Pg/Build combo - local suparches=$(get_arches "${sums}") - if [ -n "${suparches}" ]; then - return; - fi - fi - - if [ -n "${build}" ]; then - get_sums_for_build "${ver}" "${vm}" "${pkg}" "${build}" - else - for build in ${supported_builds} - do - get_sums_for_build "${ver}" "${vm}" "${pkg}" "${build}" - done - fi - chmod +x "${ofile_sums}" "${ofile_build_time}" -} - diff --git a/config/hotspot.config b/config/hotspot.config deleted file mode 100644 index 2243f3a53..000000000 --- a/config/hotspot.config +++ /dev/null @@ -1,436 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Add distributions here (names come from the distro privider at Docker Hub -OS: alpine focal jammy centos ubi9-minimal windowsservercore-1809 nanoserver-1809 windowsservercore-ltsc2022 nanoserver-ltsc2022 -Versions: 8 11 17 21 - -# -# The section below is split into versions and then JDK and JRE config definitions -# Scroll through and you'll understand the pattern. -# - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le -OS_Family: linux -Directory: 8/jdk/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le -OS_Family: linux -Directory: 8/jdk/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 8/jdk/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 8/jdk/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 8/jdk/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 8/jdk/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 8/jdk/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 8/jdk/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 8/jdk/windows/nanoserver-ltsc2022 - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le -OS_Family: linux -Directory: 8/jre/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le -OS_Family: linux -Directory: 8/jre/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 8/jre/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 8/jre/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 8/jre/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 8/jre/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 8/jre/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 8/jre/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 8/jre/windows/nanoserver-ltsc2022 - -###################################################################### - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jdk/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jdk/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 11/jdk/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jdk/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 11/jdk/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 11/jdk/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 11/jdk/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 11/jdk/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 11/jdk/windows/nanoserver-ltsc2022 - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jre/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jre/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 11/jre/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 11/jre/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 11/jre/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 11/jre/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 11/jre/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 11/jre/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 11/jre/windows/nanoserver-ltsc2022 - -###################################################################### - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jdk/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jdk/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 17/jdk/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jdk/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 17/jdk/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 17/jdk/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 17/jdk/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 17/jdk/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 17/jdk/windows/nanoserver-ltsc2022 - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jre/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jre/ubuntu/focal - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le -OS_Family: linux -Directory: 17/jre/centos - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 17/jre/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: x86_64 -OS_Family: alpine-linux -Directory: 17/jre/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 17/jre/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 17/jre/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 17/jre/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 17/jre/windows/nanoserver-ltsc2022 - -###################################################################### - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 21/jdk/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 21/jdk/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: aarch64 x86_64 -OS_Family: alpine-linux -Directory: 21/jdk/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 21/jdk/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 21/jdk/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 21/jdk/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 21/jdk/windows/nanoserver-ltsc2022 - -Build: releases -Type: full -Architectures: aarch64 armv7l x86_64 ppc64le s390x -OS_Family: linux -Directory: 21/jre/ubuntu/jammy - -Build: releases -Type: full -Architectures: aarch64 x86_64 ppc64le s390x -OS_Family: linux -Directory: 21/jre/ubi/ubi9-minimal - -Build: releases -Type: full -Architectures: aarch64 x86_64 -OS_Family: alpine-linux -Directory: 21/jre/alpine - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 21/jre/windows/windowsservercore-1809 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 21/jre/windows/nanoserver-1809 - -Build: releases -Type: full -Architectures: windows-amd -OS_Family: windows -Directory: 21/jre/windows/windowsservercore-ltsc2022 - -Build: releases -Type: full -Architectures: windows-nano -OS_Family: windows -Directory: 21/jre/windows/nanoserver-ltsc2022 diff --git a/config/hotspot.yml b/config/hotspot.yml new file mode 100644 index 000000000..0f20ccf02 --- /dev/null +++ b/config/hotspot.yml @@ -0,0 +1,65 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +supported_distributions: + OS: [alpine, focal, jammy, centos, ubi9-minimal, windowsservercore-1809, nanoserver-1809, windowsservercore-ltsc2022, nanoserver-ltsc2022] + Versions: [8, 11, 17, 21] + +configurations: + - directory: ubuntu/jammy + image: ubuntu:22.04 + architectures: [aarch64, armv7l, ppc64le, s390x, x64] + os: ubuntu + + - directory: ubuntu/focal + architectures: [aarch64, armv7l, ppc64le, s390x, x64] + image: ubuntu:20.04 + deprecated: 20 + os: ubuntu + + - directory: centos + architectures: [aarch64, ppc64le, x64] + image: centos:7 + deprecated: 20 + os: centos + + - directory: ubi/ubi9-minimal + architectures: [aarch64, ppc64le, s390x, x64] + image: redhat/ubi9-minimal + os: ubi9-minimal + + - directory: alpine + architectures: [aarch64, x64] + image: alpine:3.18 + os: alpine-linux + + - directory: windows/windowsservercore-1809 + architectures: [x64] + image: mcr.microsoft.com/windows/servercore:1809 + os: servercore + + - directory: windows/nanoserver-1809 + architectures: [x64] + image: mcr.microsoft.com/windows/nanoserver:1809 + os: nanoserver + + - directory: windows/windowsservercore-ltsc2022 + architectures: [x64] + image: mcr.microsoft.com/windows/servercore:ltsc2022 + os: servercore + + - directory: windows/nanoserver-ltsc2022 + architectures: [x64] + image: mcr.microsoft.com/windows/nanoserver:ltsc2022 + os: nanoserver diff --git a/docker_templates/alpine-linux.Dockerfile.j2 b/docker_templates/alpine-linux.Dockerfile.j2 new file mode 100644 index 000000000..8c751be21 --- /dev/null +++ b/docker_templates/alpine-linux.Dockerfile.j2 @@ -0,0 +1,22 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +# fontconfig and ttf-dejavu added to support serverside image generation by Java programs +# java-cacerts added to support adding CA certificates to the Java keystore +# bash is required for the entrypoint script (s. https://github.com/adoptium/containers/issues/415) +RUN apk add --no-cache fontconfig java-cacerts bash libretls musl-locales musl-locales-lang ttf-dejavu tzdata zlib \ + && rm -rf /var/cache/apk/* + +ENV JAVA_VERSION {{ java_version }} + +RUN set -eux; \ + ARCH="$(apk --print-arch)"; \ +{% include 'partials/multi-arch-install.j2' %} + +{% include 'partials/version-check.j2' %} +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/centos.Dockerfile.j2 b/docker_templates/centos.Dockerfile.j2 new file mode 100644 index 000000000..5fb0d7d4f --- /dev/null +++ b/docker_templates/centos.Dockerfile.j2 @@ -0,0 +1,19 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN yum install -y tzdata openssl curl wget ca-certificates fontconfig gzip tar {% if version|int >= 13 %}binutils {% endif %}\ + && yum clean all + +ENV JAVA_VERSION {{ java_version }} + +RUN set -eux; \ + ARCH="$(objdump="$(command -v objdump)" && objdump --file-headers "$objdump" | awk -F '[:,]+[[:space:]]+' '$1 == "architecture" { print $2 }')"; \ +{% include 'partials/multi-arch-install.j2' %} + +{% include 'partials/version-check.j2' %} +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/nanoserver.Dockerfile.j2 b/docker_templates/nanoserver.Dockerfile.j2 new file mode 100644 index 000000000..d40f7fd9b --- /dev/null +++ b/docker_templates/nanoserver.Dockerfile.j2 @@ -0,0 +1,20 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +SHELL ["cmd", "/s", "/c"] + +ENV JAVA_VERSION {{ java_version }} + +ENV JAVA_HOME C:\\openjdk-{{ version }} +# "ERROR: Access to the registry path is denied." +USER ContainerAdministrator +RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \ + && setx /M PATH %JAVA_HOME%\bin;%PATH% \ + && echo Complete. +USER ContainerUser + +COPY --from=eclipse-temurin:{{ arch_data.copy_from }} $JAVA_HOME $JAVA_HOME + +{% include 'partials/version-check.j2' %} +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/partials/jshell.j2 b/docker_templates/partials/jshell.j2 new file mode 100644 index 000000000..9a2e187e8 --- /dev/null +++ b/docker_templates/partials/jshell.j2 @@ -0,0 +1,3 @@ +{% if image_type == "jdk" and version|int >= 11 %} +CMD ["jshell"] +{% endif -%} diff --git a/docker_templates/partials/license.j2 b/docker_templates/partials/license.j2 new file mode 100644 index 000000000..affaabf52 --- /dev/null +++ b/docker_templates/partials/license.j2 @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------------ +# NOTE: THIS DOCKERFILE IS GENERATED VIA "generate_dockerfiles.py" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# ------------------------------------------------------------------------------ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/docker_templates/partials/multi-arch-install.j2 b/docker_templates/partials/multi-arch-install.j2 new file mode 100644 index 000000000..7af8485f9 --- /dev/null +++ b/docker_templates/partials/multi-arch-install.j2 @@ -0,0 +1,28 @@ + case "${ARCH}" in \ + {% for architecture, details in arch_data.items() -%} + {{ architecture }}) \ + ESUM='{{ details.checksum }}'; \ + BINARY_URL='{{ details.download_url }}'; \ + {% if architecture == "armhf|arm" and os == "ubuntu" and version|int == 8 -%} + # Fixes libatomic.so.1: cannot open shared object file + apt-get update \\ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libatomic1 \\ + && rm -rf /var/lib/apt/lists/* \\ + {% endif -%} + ;; \ + {% endfor -%} + *) \ + echo "Unsupported arch: ${ARCH}"; \ + exit 1; \ + ;; \ + esac; \ + wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ + echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ + mkdir -p "$JAVA_HOME"; \ + tar --extract \ + --file /tmp/openjdk.tar.gz \ + --directory "$JAVA_HOME" \ + --strip-components 1 \ + --no-same-owner \ + ; \ + rm -f /tmp/openjdk.tar.gz ${JAVA_HOME}/lib/src.zip; \ No newline at end of file diff --git a/docker_templates/partials/nix-env.j2 b/docker_templates/partials/nix-env.j2 new file mode 100644 index 000000000..3a8a7e247 --- /dev/null +++ b/docker_templates/partials/nix-env.j2 @@ -0,0 +1,5 @@ +ENV JAVA_HOME /opt/java/openjdk +ENV PATH $JAVA_HOME/bin:$PATH + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' diff --git a/docker_templates/partials/version-check-windows.j2 b/docker_templates/partials/version-check-windows.j2 new file mode 100644 index 000000000..780eb25a4 --- /dev/null +++ b/docker_templates/partials/version-check-windows.j2 @@ -0,0 +1,14 @@ +RUN Write-Host 'Verifying install ...'; \ + {% if version|int >= 11 -%} + {% if image_type == "jdk" -%} + Write-Host 'javac --version'; javac --version; \ + {% endif -%} + Write-Host 'java --version'; java --version; \ + {% else -%} + {% if image_type == "jdk" -%} + Write-Host 'javac -version'; javac -version; \ + {% endif -%} + Write-Host 'java -version'; java -version; \ + {% endif -%} + \ + Write-Host 'Complete.' \ No newline at end of file diff --git a/docker_templates/partials/version-check.j2 b/docker_templates/partials/version-check.j2 new file mode 100644 index 000000000..1f76ec587 --- /dev/null +++ b/docker_templates/partials/version-check.j2 @@ -0,0 +1,16 @@ +RUN echo Verifying install ... \ + {% if version|int >= 11 -%} + {% if os_family != "windows" -%} + && fileEncoding="$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java \ + {% endif -%} + {% if image_type == "jdk" -%} + && echo javac --version && javac --version \ + {% endif -%} + && echo java --version && java --version \ + {% else -%} + {% if image_type == "jdk" -%} + && echo javac -version && javac -version \ + {% endif -%} + && echo java -version && java -version \ + {% endif -%} + && echo Complete. \ No newline at end of file diff --git a/scripts/entrypoint.alpine.sh b/docker_templates/scripts/entrypoint.alpine-linux.sh similarity index 100% rename from scripts/entrypoint.alpine.sh rename to docker_templates/scripts/entrypoint.alpine-linux.sh diff --git a/scripts/entrypoint.centos.sh b/docker_templates/scripts/entrypoint.centos.sh similarity index 100% rename from scripts/entrypoint.centos.sh rename to docker_templates/scripts/entrypoint.centos.sh diff --git a/scripts/entrypoint.ubi9-minimal.sh b/docker_templates/scripts/entrypoint.ubi9-minimal.sh similarity index 100% rename from scripts/entrypoint.ubi9-minimal.sh rename to docker_templates/scripts/entrypoint.ubi9-minimal.sh diff --git a/scripts/entrypoint.focal.sh b/docker_templates/scripts/entrypoint.ubuntu.sh similarity index 100% rename from scripts/entrypoint.focal.sh rename to docker_templates/scripts/entrypoint.ubuntu.sh diff --git a/docker_templates/servercore.Dockerfile.j2 b/docker_templates/servercore.Dockerfile.j2 new file mode 100644 index 000000000..45d0e6d83 --- /dev/null +++ b/docker_templates/servercore.Dockerfile.j2 @@ -0,0 +1,34 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +ENV JAVA_VERSION {{ java_version }} + +RUN Write-Host ('Downloading {{ arch_data.download_url }} ...'); \ + curl.exe -LfsSo openjdk.msi {{ arch_data.download_url }} ; \ + Write-Host ('Verifying sha256 ({{ arch_data.checksum }}) ...'); \ + if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '{{ arch_data.checksum }}') { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + \ + Write-Host 'Installing using MSI ...'; \ + $proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \ + '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-{{ version }}' -Wait -Passthru; \ + $proc.WaitForExit() ; \ + if ($proc.ExitCode -ne 0) { \ + Write-Host 'FAILED installing MSI!' ; \ + exit 1; \ + }; \ + \ + Remove-Item -Path C:\temp -Recurse | Out-Null; \ + Write-Host 'Removing openjdk.msi ...'; \ + Remove-Item openjdk.msi -Force + +{% include 'partials/version-check-windows.j2' %} +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/ubi9-minimal.Dockerfile.j2 b/docker_templates/ubi9-minimal.Dockerfile.j2 new file mode 100644 index 000000000..083d16d19 --- /dev/null +++ b/docker_templates/ubi9-minimal.Dockerfile.j2 @@ -0,0 +1,19 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN microdnf install -y binutils tzdata openssl wget ca-certificates fontconfig glibc-langpack-en gzip tar \ + && microdnf clean all + +ENV JAVA_VERSION {{ java_version }} + +RUN set -eux; \ + ARCH="$(objdump="$(command -v objdump)" && objdump --file-headers "$objdump" | awk -F '[:,]+[[:space:]]+' '$1 == "architecture" { print $2 }')"; \ +{% include 'partials/multi-arch-install.j2' %} + +{% include 'partials/version-check.j2' %} +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/docker_templates/ubuntu.Dockerfile.j2 b/docker_templates/ubuntu.Dockerfile.j2 new file mode 100644 index 000000000..ff5b6e8c5 --- /dev/null +++ b/docker_templates/ubuntu.Dockerfile.j2 @@ -0,0 +1,31 @@ +{% include 'partials/license.j2' %} + +FROM {{ base_image }} + +{% include 'partials/nix-env.j2' %} + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata curl wget ca-certificates fontconfig locales p11-kit {% if version|int >= 13 %}binutils {% endif %}\ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && rm -rf /var/lib/apt/lists/* + +ENV JAVA_VERSION {{ java_version }} + +RUN set -eux; \ + ARCH="$(dpkg --print-architecture)"; \ +{% include 'partials/multi-arch-install.j2' %} \ + # https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 + find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \ + {% if version|int >= 11 -%} + ldconfig; \ + # https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 + # https://openjdk.java.net/jeps/341 + java -Xshare:dump; +{% else -%} + ldconfig; +{% endif %} +{% include 'partials/version-check.j2' %} +COPY entrypoint.sh /__cacert_entrypoint.sh +ENTRYPOINT ["/__cacert_entrypoint.sh"] +{% include 'partials/jshell.j2' %} \ No newline at end of file diff --git a/dockerfile_functions.sh b/dockerfile_functions.sh deleted file mode 100755 index 2bc1f80a9..000000000 --- a/dockerfile_functions.sh +++ /dev/null @@ -1,922 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1083,SC2086,SC2154 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Generate the common license and copyright header -print_legal() { - cat > "$1" <<-EOI - # ------------------------------------------------------------------------------ - # NOTE: THIS DOCKERFILE IS GENERATED VIA "update_multiarch.sh" - # - # PLEASE DO NOT EDIT IT DIRECTLY. - # ------------------------------------------------------------------------------ - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # https://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - # - - EOI -} - -# Print the supported Ubuntu OS -print_ubuntu_ver() { - local os=$4 - case $os in - focal) os_version="20.04" ;; - jammy) os_version="22.04" ;; - esac - - cat >> "$1" <<-EOI - FROM ubuntu:${os_version} - - EOI -} - -# Print the supported Debian OS -print_debian_ver() { - os_version="buster" - - cat >> "$1" <<-EOI - FROM debian:${os_version} - - EOI -} - -# Print the supported Debian OS -print_debianslim_ver() { - os_version="buster-slim" - - cat >> "$1" <<-EOI - FROM debian:${os_version} - - EOI -} - -print_ubi_ver() { - local os=$4 - - cat >> "$1" <<-EOI - FROM redhat/${os} - - EOI -} - -print_ubi-minimal_ver() { - local os=$4 - - cat >> "$1" <<-EOI - FROM redhat/${os} - - EOI -} - -print_centos_ver() { - os_version="7" - - cat >> "$1" <<-EOI - FROM centos:${os_version} - - EOI -} - -print_clefos_ver() { - os_version="7" - - cat >> "$1" <<-EOI - FROM clefos:${os_version} - - EOI -} - -print_leap_ver() { - os_version="15.3" - - cat >> "$1" <<-EOI - FROM opensuse/leap:${os_version} - - EOI -} - -print_tumbleweed_ver() { - os_version="latest" - - cat >> "$1" <<-EOI - FROM opensuse/tumbleweed:${os_version} - - EOI -} - -# Print the supported Windows OS -print_windows_ver() { - local os=$4 - case $os in - *ltsc2019) os_version="ltsc2019" ;; - *1909) os_version="1909" ;; - *1809) os_version="1809" ;; - *ltsc2022) os_version="ltsc2022" ;; - esac - - servertype=$(echo "$file" | cut -f4 -d"/") - nanoserver_pat="nanoserver.*" - if [[ "$servertype" =~ ${nanoserver_pat} ]]; then - cat >> "$1" <<-EOI - FROM mcr.microsoft.com/windows/nanoserver:${os_version} - -EOI - else - cat >> "$1" <<-EOI - FROM mcr.microsoft.com/windows/servercore:${os_version} - -EOI - fi - -} - -# Print the supported Alpine OS - this is for musl based images -print_alpine_ver() { - cat >> "$1" <<-EOI - FROM alpine:3.18 - - EOI -} - -# Print the locale and language -print_lang_locale() { - local os=$2 - if [ "$os" != "windows" ]; then - cat >> "$1" <<-EOI -# Default to UTF-8 file.encoding -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' - - EOI - fi -} - -# Select the ubuntu OS packages -print_ubuntu_pkg() { - # p11-kit provides the `trust` binary used in certificate extraction - packages="tzdata curl wget ca-certificates fontconfig locales p11-kit" - # binutils is needed on JDK13+ for jlink to work https://github.com/docker-library/openjdk/issues/351 - if [[ $version -ge 13 ]]; then - packages+=" binutils" - fi - cat >> "$1" <> /etc/locale.gen \\ - && locale-gen en_US.UTF-8 \\ - && rm -rf /var/lib/apt/lists/* -EOI -} - -print_debian_pkg() { - print_ubuntu_pkg "$1" -} - -print_debianslim_pkg() { - print_ubuntu_pkg "$1" -} - -print_windows_pkg() { - servertype=$(echo "$file" | cut -f4 -d"/") - nanoserver_pat="nanoserver.*" - if [[ "$servertype" =~ ${nanoserver_pat} ]]; then - cat >> "$1" <<'EOI' -SHELL ["cmd", "/s", "/c"] -EOI - else - cat >> "$1" <<'EOI' -# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -EOI - fi -} - -# Select the alpine musl OS packages. -# TODO we could inline this code as we now support only musl and not (musl and glibc) -print_alpine_pkg() { - local osfamily=$2 - - if [ "${osfamily}" == "alpine-linux" ]; then - print_alpine_musl_pkg "$1" "$2" - fi - -} - -# Select the alpine OS musl based packages. -print_alpine_musl_pkg() { - cat >> "$1" <<'EOI' -# fontconfig and ttf-dejavu added to support serverside image generation by Java programs -# java-cacerts added to support adding CA certificates to the Java keystore -# bash is required for the entrypoint script (s. https://github.com/adoptium/containers/issues/415) -RUN apk add --no-cache fontconfig java-cacerts bash libretls musl-locales musl-locales-lang ttf-dejavu tzdata zlib \ - && rm -rf /var/cache/apk/* -EOI -} - -# Select the ubi OS packages. -print_ubi_pkg() { - cat >> "$1" <<'EOI' -RUN dnf install -y binutils tzdata openssl wget ca-certificates fontconfig glibc-langpack-en gzip tar \ - && dnf clean all -EOI -} - -# Select the ubi OS packages. -print_ubi-minimal_pkg() { - cat >> "$1" <<'EOI' -RUN microdnf install -y binutils tzdata openssl wget ca-certificates fontconfig glibc-langpack-en gzip tar \ - && microdnf clean all -EOI -} - -# Select the CentOS packages. -print_centos_pkg() { - packages="tzdata openssl curl wget ca-certificates fontconfig gzip tar" - # binutils is needed on JDK13+ for jlink to work https://github.com/docker-library/openjdk/issues/351 - if [[ $version -ge 13 ]]; then - packages+=" binutils" - fi - cat >> "$1" <> "$1" <<'EOI' -RUN zypper install --no-recommends -y timezone openssl wget ca-certificates fontconfig gzip tar \ - && zypper update -y; zypper clean --all -EOI -} - -# Select the Tumbleweed packages. -print_tumbleweed_pkg() { - print_leap_pkg "$1" -} - -# Print the Java version that is being installed here -print_env() { - local osfamily=$2 - local os=$3 - - # shellcheck disable=SC2154 - shasums="${package}"_"${vm}"_"${version}"_"${build}"_sums - if [ "${osfamily}" == "windows" ]; then - # Sometimes the windows version can differ from the Linux one - jverinfo="${shasums}[version-windows_windows-amd]" - elif [ "${osfamily}" == "alpine-linux" ]; then - # Sometimes the alpine linux version can differ from the Linux one - jverinfo="${shasums}[version-alpine-linux_x86_64]" - else - jverinfo="${shasums}[version]" - fi - # shellcheck disable=SC1083,SC2086 # TODO not sure about intention here - eval jver=\${$jverinfo} - jver="${jver}" # to satifsy shellcheck SC2154 - # Print additional label for UBI alone - if [ "${os}" == "ubi-minimal" ] || [ "${os}" == "ubi" ]; then - cat >> "$1" <<-EOI - -LABEL name="Temurin OpenJDK" \\ - vendor="Eclipse Foundation" \\ - version="${jver}" \\ - release="${version}" \\ - run="docker run --rm -ti /bin/bash" \\ - summary="Eclipse Temurin Docker Image for OpenJDK with ${vm} and ${os}" \\ - description="For more information on this image please see https://github.com/adoptium/containers/blob/main/README.md" -EOI - fi - - cat >> "$1" <<-EOI - -ENV JAVA_VERSION ${jver} - -EOI -} - -# OS independent portion (Works for both Alpine and Ubuntu) -print_java_install_pre() { - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - local reldir="openjdk${version}"; - - if [ "${vm}" != "hotspot" ]; then - reldir="${reldir}-${vm}"; - fi - # First get the arches for which the builds are available as per shasums file - local sup_arches_for_build=$(get_arches "${shasums}" | sort | uniq) - # Next, check the arches that are supported for the underlying OS - local sup_arches_for_os=$(parse_vm_entry "${vm}" "${version}" "${pkg}" "${os}" "Architectures:") - # Now the actual arches are the intersection of the above two - local merge_arches="${sup_arches_for_build} ${sup_arches_for_os}" - local supported_arches=$(echo ${merge_arches} | tr ' ' '\n' | sort | uniq -d) - for sarch in ${supported_arches} - do - if [ "${sarch}" == "aarch64" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" aarch64 "${osfamily}"); - cat >> "$1" <<-EOI - aarch64|arm64) \\ - ESUM='$(get_shasum "${shasums}" aarch64 "${osfamily}")'; \\ - BINARY_URL='$(get_v3_binary_url "${JAVA_URL}")'; \\ - ;; \\ - EOI - elif [ "${sarch}" == "armv7l" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" arm "${osfamily}"); - cat >> "$1" <<-EOI - armhf|arm) \\ - ESUM='$(get_shasum "${shasums}" armv7l "${osfamily}")'; \\ - BINARY_URL='$(get_v3_binary_url "${JAVA_URL}")'; \\ - EOI - if [ "${version}" == "8" ] && [ "${vm}" == "hotspot" ]; then - if [ "${os}" == "focal" ] || [ "${os}" == "jammy" ]; then - cat >> "$1" <<-EOI - # Fixes libatomic.so.1: cannot open shared object file - apt-get update \\ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libatomic1 \\ - && rm -rf /var/lib/apt/lists/* \\ - EOI - fi - fi - cat >> "$1" <<-EOI - ;; \\ - EOI - elif [ "${sarch}" == "ppc64le" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" ppc64le "${osfamily}"); - cat >> "$1" <<-EOI - ppc64el|powerpc:common64) \\ - ESUM='$(get_shasum "${shasums}" ppc64le "${osfamily}")'; \\ - BINARY_URL='$(get_v3_binary_url "${JAVA_URL}")'; \\ - ;; \\ - EOI - elif [ "${sarch}" == "s390x" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" s390x "${osfamily}"); - cat >> "$1" <<-EOI - s390x|s390:64-bit) \\ - ESUM='$(get_shasum "${shasums}" s390x "${osfamily}")'; \\ - BINARY_URL='$(get_v3_binary_url "${JAVA_URL}")'; \\ - EOI - # Ubuntu 20.04 has a newer version of libffi (libffi7) - # whereas hotspot has been built on libffi6 and fails if that is not avaialble - # Workaround is to install libffi6 on ubuntu / hotspot / s390x - if [ "${version}" == "8" ] && [ "${vm}" == "hotspot" ] && [ "${os}" == "ubuntu" ]; then - cat >> "$1" <<'EOI' - LIBFFI_SUM='05e456a2e8ad9f20db846ccb96c483235c3243e27025c3e8e8e358411fd48be9'; \ - LIBFFI_URL='http://launchpadlibrarian.net/354371408/libffi6_3.2.1-8_s390x.deb'; \ - curl -LfsSo /tmp/libffi6.deb ${LIBFFI_URL}; \ - echo "${LIBFFI_SUM} /tmp/libffi6.deb" | sha256sum -c -; \ - apt-get install -y --no-install-recommends /tmp/libffi6.deb; \ - rm -rf /tmp/libffi6.deb; \ -EOI - fi - cat >> "$1" <<-EOI - ;; \\ - EOI - elif [ "${sarch}" == "x86_64" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" x64 "${osfamily}"); - if [ "${osfamily}" == "alpine-linux" ]; then - print_arch="amd64|x86_64" - else - print_arch="amd64|i386:x86-64" - fi - cat >> "$1" <<-EOI - ${print_arch}) \\ - ESUM='$(get_shasum "${shasums}" x86_64 "${osfamily}")'; \\ - BINARY_URL='$(get_v3_binary_url "${JAVA_URL}")'; \\ - ;; \\ - EOI - fi - done - cat >> "$1" <<-EOI - *) \\ - echo "Unsupported arch: \${ARCH}"; \\ - exit 1; \\ - ;; \\ - esac; \\ -EOI -cat >> "$1" <<'EOI' - wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \ - echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \ - mkdir -p "$JAVA_HOME"; \ - tar --extract \ - --file /tmp/openjdk.tar.gz \ - --directory "$JAVA_HOME" \ - --strip-components 1 \ - --no-same-owner \ - ; \ -EOI -} - -print_java_install_post() { - cat >> "$1" <<-EOI - rm -f /tmp/openjdk.tar.gz \${JAVA_HOME}/lib/src.zip; -EOI -} - -print_ubuntu_java_install_post() { - above_8="^(9|[1-9][0-9]+)$" - cat >> "$1" <<-EOI - rm -f /tmp/openjdk.tar.gz \${JAVA_HOME}/lib/src.zip; \\ -# https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472 - find "\$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \\ -EOI - if [[ "${version}" =~ ${above_8} ]]; then - cat >> "$1" <<-EOI - ldconfig; \\ -# https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840 -# https://openjdk.java.net/jeps/341 - java -Xshare:dump; -EOI - else - cat >> "$1" <<-EOI - ldconfig; -EOI - fi -} - -# Call the script to create the slim package for Ubuntu -# Install binutils for this phase as we need the "strip" command -# Uninstall once done -print_ubuntu_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - apt-get update; apt-get install -y --no-install-recommends binutils; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ - apt-get remove -y binutils; \\ - rm -rf /var/lib/apt/lists/*; \\ -EOI -} - -print_debianslim_package() { - print_ubuntu_slim_package "$1" -} - -# Call the script to create the slim package for Windows -print_windowsservercore_slim_package() { - cat >> "$1" <<-EOI - & C:/ProgramData/Java/slim-java.ps1 (Get-ChildItem -Path 'C:\\Program Files\\AdoptOpenJDK')[0].FullName; \\ -EOI -} - -print_nanoserver_slim_package() { - cat >> "$1" <<-EOI - & C:/ProgramData/Java/slim-java.ps1 C:\\openjdk-$2; \\ -EOI -} - -# Call the script to create the slim package for Alpine -# Install binutils for this phase as we need the "strip" command -# Uninstall once done -print_alpine_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - apk add --no-cache --virtual .build-deps bash binutils; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ - apk del --purge .build-deps; \\ - rm -rf /var/cache/apk/*; \\ -EOI -} - -# Call the script to create the slim package for Ubi -print_ubi_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - dnf install -y binutils; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ - dnf remove -y binutils; \\ - dnf clean all; \\ -EOI -} - -# Call the script to create the slim package for Ubi-minimal -print_ubi-minimal_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - microdnf install -y binutils; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ - microdnf remove -y binutils; \\ - microdnf clean all; \\ -EOI -} - -# Call the script to create the slim package for leap & tumbleweed -print_leap_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - zypper install --no-recommends -y binutils; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ - zypper remove -y binutils; \\ - zypper clean --all; \\ -EOI -} - -# Call the script to create the slim package for Centos & clefos -print_centos_slim_package() { - cat >> "$1" <<-EOI - export PATH="${jhome}/bin:\$PATH"; \\ - /usr/local/bin/slim-java.sh ${jhome}; \\ -EOI -} - -# Print the main RUN command that installs Java on ubuntu. -print_ubuntu_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - - cat >> "$1" <<-EOI -RUN set -eux; \\ - ARCH="\$(dpkg --print-architecture)"; \\ - case "\${ARCH}" in \\ -EOI - print_java_install_pre "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}" - if [ "${btype}" == "slim" ]; then - print_ubuntu_slim_package "$1" - fi - print_ubuntu_java_install_post "$1" -} - -print_debian_java_install() { - print_ubuntu_java_install "$1" "$2" "$3" "$4" "$5" "$6" -} - -print_debianslim_java_install() { - print_ubuntu_java_install "$1" "$2" "$3" "$4" "$5" "$6" -} - -print_windows_java_install_post() { - local servertype="$2" - local version="$3" - local os=$4 - - case $os in - *ltsc2022) os_version="ltsc2022" ;; - *ltsc2019) os_version="ltsc2019" ;; - *1909) os_version="1909" ;; - *1809) os_version="1809" ;; - esac - - if [ "${servertype}" == "windowsservercore" ]; then - cat >> "$1" <<-EOI - Write-Host 'Removing openjdk.msi ...'; \\ - Remove-Item openjdk.msi -Force -EOI - else - copy_version=$(echo $jver | tr -d "jdk" | tr + _) - if [[ "$version" != "8" ]]; then - copy_version=$(echo $copy_version | tr -d "-") - fi - cat >> "$1" <<-EOI -ENV JAVA_HOME C:\\\\openjdk-${version} -# "ERROR: Access to the registry path is denied." -USER ContainerAdministrator -RUN echo Updating PATH: %JAVA_HOME%\bin;%PATH% \\ - && setx /M PATH %JAVA_HOME%\bin;%PATH% \\ - && echo Complete. -USER ContainerUser - -COPY --from=eclipse-temurin:${copy_version}-${pkg}-windowsservercore-${os_version} \$JAVA_HOME \$JAVA_HOME -EOI - fi -} - -# Print the main RUN command that installs Java on ubuntu. -print_windows_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - local os=$5 - - local servertype=$(echo -n "${file}" | cut -f4 -d"/" | cut -f1 -d"-" | head -qn1) - local serverversion=$(echo -n "${file}" | cut -f4 -d"/" | cut -f2 -d"-" | head -qn1) - local version=$(echo -n "${file}" | cut -f1 -d "/" | head -qn1) - if [ "${servertype}" == "windowsservercore" ]; then - JAVA_URL=$(get_v3_url feature_releases "${bld}" "${vm}" "${pkg}" windows-amd windows); - ESUM=$(get_shasum "${shasums}" windows-amd "${osfamily}"); - BINARY_URL=$(get_v3_installer_url "${JAVA_URL}"); - - DOWNLOAD_COMMAND="curl.exe -LfsSo openjdk.msi ${BINARY_URL}" - - cat >> "$1" <<-EOI -RUN Write-Host ('Downloading ${BINARY_URL} ...'); \\ - ${DOWNLOAD_COMMAND} ; \\ - Write-Host ('Verifying sha256 (${ESUM}) ...'); \\ - if ((Get-FileHash openjdk.msi -Algorithm sha256).Hash -ne '${ESUM}') { \\ - Write-Host 'FAILED!'; \\ - exit 1; \\ - }; \\ - \\ - New-Item -ItemType Directory -Path C:\temp | Out-Null; \\ - \\ - Write-Host 'Installing using MSI ...'; \\ - \$proc = Start-Process -FilePath "msiexec.exe" -ArgumentList '/i', 'openjdk.msi', '/L*V', 'C:\temp\OpenJDK.log', \\ - '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', 'INSTALLDIR=C:\openjdk-${version}' -Wait -Passthru; \\ - \$proc.WaitForExit() ; \\ - if (\$proc.ExitCode -ne 0) { \\ - Write-Host 'FAILED installing MSI!' ; \\ - exit 1; \\ - }; \\ - \\ - Remove-Item -Path C:\temp -Recurse | Out-Null; \\ -EOI - fi - - if [ "${btype}" == "slim" ]; then - print_"${servertype}"_slim_package "$1" "${version}" - fi - - print_windows_java_install_post "$1" "${servertype}" "${version}" "${os}" -} - -# Print the main RUN command that installs Java on alpine. -print_alpine_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - - cat >> "$1" <<-EOI -RUN set -eux; \\ - ARCH="\$(apk --print-arch)"; \\ - case "\${ARCH}" in \\ -EOI - print_java_install_pre "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}" - if [ "${btype}" == "slim" ]; then - print_alpine_slim_package "$1" - fi - print_java_install_post "$1" -} - -# Print the main RUN command that installs Java on ubi -print_ubi_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - - cat >> "$1" <<-EOI -RUN set -eux; \\ - ARCH="\$(objdump="\$(command -v objdump)" && objdump --file-headers "\$objdump" | awk -F '[:,]+[[:space:]]+' '\$1 == "architecture" { print \$2 }')"; \\ - case "\${ARCH}" in \\ -EOI - print_java_install_pre "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}" - if [ "${btype}" == "slim" ]; then - if [ "${os}" == "ubi" ]; then - print_ubi_slim_package "$1" - elif [ "${os}" == "ubi-minimal" ]; then - print_ubi-minimal_slim_package "$1" - fi - fi - print_java_install_post "$1" -} - -# Print the main RUN command that installs Java on ubi-minimal -print_ubi-minimal_java_install() { - print_ubi_java_install "$1" "$2" "$3" "$4" "$5" "$6" -} - -# Print the main RUN command that installs Java on CentOS -print_centos_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - - cat >> "$1" <<-EOI -RUN set -eux; \\ - ARCH="\$(objdump="\$(command -v objdump)" && objdump --file-headers "\$objdump" | awk -F '[:,]+[[:space:]]+' '\$1 == "architecture" { print \$2 }')"; \\ - case "\${ARCH}" in \\ -EOI - print_java_install_pre "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}" - if [ "${btype}" == "slim" ]; then - print_centos_slim_package "$1" - fi - print_java_install_post "$1" -} - -# Print the main RUN command that installs Java on ClefOS -print_clefos_java_install() { - print_centos_java_install "$1" "$2" "$3" "$4" "$5" "$6" -} - -# Print the main RUN command that installs Java on Leap -print_leap_java_install() { - local pkg=$2 - local bld=$3 - local btype=$4 - cat >> "$1" <<-EOI -RUN set -eux; \\ - ARCH="\$(uname -m)"; \\ - case "\${ARCH}" in \\ -EOI - print_java_install_pre "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}" - if [ "${btype}" == "slim" ]; then - print_leap_slim_package "$1" - fi - print_java_install_post "$1" -} - -# Print the main RUN command that installs Java on Tumbleweed -print_tumbleweed_java_install() { - print_leap_java_install "$1" "$2" "$3" "$4" "$5" "$6" -} - -# Print the JAVA_HOME and PATH. -# Currently Java is installed at a fixed path "/opt/java/openjdk" -print_java_env() { - # e.g 11 or 8 - local version=$(echo "$file" | cut -f1 -d"/") - local os=$4 - - if [ "$os" != "windows" ]; then - cat >> "$1" <<-EOI -ENV JAVA_HOME ${jhome} -ENV PATH \$JAVA_HOME/bin:\$PATH - -EOI - fi -} - -# Turn on JVM specific optimization flags. -print_java_options() { - case ${version} in - 9) # Hotspot@JDK9: https://bugs.openjdk.java.net/browse/JDK-8189497 - JOPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"; - ;; - esac - - if [ -n "${JOPTS}" ]; then - cat >> "$1" <<-EOI -ENV JAVA_TOOL_OPTIONS="${JOPTS}" -EOI - fi -} - -# For slim builds copy the slim script and related config files. -copy_slim_script() { - if [ "${btype}" == "slim" ]; then - if [ "${osfamily}" == "windows" ]; then - cat >> "$1" <<-EOI -COPY slim-java* C:/ProgramData/Java/ - -EOI - else - cat >> "$1" <<-EOI -COPY slim-java* /usr/local/bin/ - -EOI - fi - fi -} - -print_test() { - above_8="^(9|[1-9][0-9]+)$" - if [[ "${version}" =~ ${above_8} ]]; then - arg="--version" - else - arg="-version" - fi - servertype=$(echo "$file" | cut -f4 -d"/") - nanoserver_pat="nanoserver.*" - if [[ "${osfamily}" != "windows" ]] || [[ "$servertype" =~ ${nanoserver_pat} ]]; then - cat >> "$1" <<-EOI - -RUN echo Verifying install ... \\ -EOI - if [[ "${version}" =~ ${above_8} ]] && [[ "${osfamily}" != "windows" ]] ; then - cat >> "$1" <<-EOI - && fileEncoding="\$(echo 'System.out.println(System.getProperty("file.encoding"))' | jshell -s -)"; [ "\$fileEncoding" = 'UTF-8' ]; rm -rf ~/.java \\ -EOI - fi - if [[ "${package}" == "jdk" ]]; then - cat >> "$1" <<-EOI - && echo javac ${arg} && javac ${arg} \\ - EOI - fi - cat >> "$1" <<-EOI - && echo java ${arg} && java ${arg} \\ - && echo Complete. - EOI - else - cat >> "$1" <<-EOI - -RUN Write-Host 'Verifying install ...'; \\ - EOI - if [[ "${package}" == "jdk" ]]; then - cat >> "$1" <<-EOI - Write-Host 'javac ${arg}'; javac ${arg}; \\ - EOI - fi - cat >> "$1" <<-EOI - Write-Host 'java ${arg}'; java ${arg}; \\ - \\ - Write-Host 'Complete.' - EOI - fi -} - -print_entrypoint() { - dir=$(dirname "$1") - - cat "scripts/entrypoint.$2.sh" > "$dir/entrypoint.sh" - chmod +x "$dir/entrypoint.sh" - cat >> "$1" < 8, set CMD["jshell"] in the Dockerfile - above_8="^(9|[1-9][0-9]+)$" - if [[ "${version}" =~ ${above_8} && "${package}" == "jdk" ]]; then - cat >> "$1" <<-EOI - - CMD ["jshell"] - EOI - fi -} - -# Generate the dockerfile for a given build, build_type and OS -generate_dockerfile() { - local file=$1 - local pkg=$2 - local bld=$3 - local btype=$4 - local osfamily=$5 - local os=$6 - - jhome="/opt/java/openjdk" - - mkdir -p "$(dirname "${file}")" 2>/dev/null - echo - echo -n "Writing ${file} ... " - print_legal "${file}"; - if [ "${osfamily}" == "windows" ]; then - print_"${osfamily}"_ver "${file}" "${bld}" "${btype}" "${os}"; - print_lang_locale "${file}" "${osfamily}"; - print_"${osfamily}"_pkg "${file}" "${osfamily}"; - print_env "${file}" "${osfamily}" "${os}"; - copy_slim_script "${file}"; - print_"${osfamily}"_java_install "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}"; - print_java_env "${file}" "${bld}" "${btype}" "${osfamily}"; - print_java_options "${file}" "${bld}" "${btype}"; - print_test "${file}"; - print_cmd "${file}"; - else - distro="${os}" - case $file in - *ubuntu*) distro="ubuntu"; ;; - *ubi*-minimal*) distro="ubi-minimal"; ;; - *ubi*) distro="ubi"; ;; - esac - print_"${distro}"_ver "${file}" "${bld}" "${btype}" "${os}"; - print_java_env "${file}" "${bld}" "${btype}" "${osfamily}"; - print_lang_locale "${file}" "${osfamily}"; - print_"${distro}"_pkg "${file}" "${osfamily}"; - print_env "${file}" "${osfamily}" "${os}"; - copy_slim_script "${file}"; - print_"${distro}"_java_install "${file}" "${pkg}" "${bld}" "${btype}" "${osfamily}" "${os}"; - print_java_options "${file}" "${bld}" "${btype}"; - print_test "${file}"; - print_entrypoint "${file}" "${os}" - print_cmd "${file}"; - fi - echo "done" - echo -} diff --git a/dockerhub_doc_config_update.sh b/dockerhub_doc_config_update.sh index 3d89c24b1..85d509621 100755 --- a/dockerhub_doc_config_update.sh +++ b/dockerhub_doc_config_update.sh @@ -22,15 +22,16 @@ # set -o pipefail -# shellcheck source=common_functions.sh -source ./common_functions.sh - if [[ -z "$1" ]]; then official_docker_image_file="eclipse-temurin" else official_docker_image_file="$1" fi +supported_versions="8 11 17 21" +all_jvms="hotspot" +all_packages="jdk jre" + # Fetch the latest manifest from the official repo wget -q -O official-eclipse-temurin https://raw.githubusercontent.com/docker-library/official-images/master/library/eclipse-temurin @@ -168,7 +169,6 @@ function print_official_image_file() { echo "Architectures: ${arches}" echo "GitCommit: ${commit}" echo "Directory: ${dfdir}" - echo "File: ${dfname}" if [ $os == "windows" ]; then echo "Constraints: ${constraints}" fi diff --git a/generate_dockerfiles.py b/generate_dockerfiles.py new file mode 100644 index 000000000..40fc9e830 --- /dev/null +++ b/generate_dockerfiles.py @@ -0,0 +1,159 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os + +import requests +import yaml +from jinja2 import Environment, FileSystemLoader + +# Setup the Jinja2 environment +env = Environment(loader=FileSystemLoader("docker_templates")) + +headers = { + "User-Agent": "Adoptium Dockerfile Updater", +} + +def archHelper(arch, os_family): + if arch == "aarch64": + return "aarch64|arm64" + elif arch == "ppc64le": + return "ppc64el|powerpc:common64" + elif arch == "s390x": + return "s390x|s390:64-bit" + elif arch == "arm": + return "armhf|arm" + elif arch == "x64": + if os_family == "alpine-linux": + return "amd64|x86_64" + else: + return "amd64|i386:x86-64" + else: + return arch + + +def osFamilyHelper(os): + if os == "ubuntu": + return "linux" + elif os == "centos": + return "linux" + elif os == "ubi9-minimal": + return "linux" + elif os == "nanoserver": + return "windows" + elif os == "servercore": + return "windows" + else: + return os + + +# Load the YAML configuration +with open("config/hotspot.yml", "r") as file: + config = yaml.safe_load(file) + +# Iterate through configurations +for configuration in config["configurations"]: + directory = configuration["directory"] + architectures = configuration["architectures"] + os_name = configuration["os"] + os_family = osFamilyHelper(os_name) + base_image = configuration["image"] + deprecated = configuration.get("deprecated", None) + versions = configuration.get( + "versions", config["supported_distributions"]["Versions"] + ) + + # Define the path for the template based on OS + template_name = f"{os_name}.Dockerfile.j2" + template = env.get_template(template_name) + + # Create output directories if they don't exist + for version in versions: + # if deprecated is set and version is greater than or equal to deprecated, skip + if deprecated and version >= deprecated: + continue + for image_type in ["jdk", "jre"]: + output_directory = os.path.join(str(version), image_type, directory) + os.makedirs(output_directory, exist_ok=True) + + # Fetch latest release for version from Adoptium API + url = f"https://api.adoptium.net/v3/assets/feature_releases/{version}/ga?page=0&image_type={image_type}&page_size=1&vendor=eclipse" + response = requests.get(url, headers=headers) + response.raise_for_status() + data = response.json() + + release = response.json()[0] + + # Extract the version number from the release name + openjdk_version = release["release_name"] + + # Generate the data for each architecture + arch_data = {} + + for binary in release["binaries"]: + if ( + binary["architecture"] in architectures + and binary["os"] == os_family + ): + if os_family == "windows": + # Windows only has x64 binaries + copy_from = openjdk_version.replace( + "jdk", "" + ) # jdk8u292-b10 -> 8u292-b10 + if version != 8: + copy_from = copy_from.replace("-", "").replace( + "+", "_" + ) # 11.0.11+9 -> 11.0.11_9 + copy_from = f"{copy_from}-{image_type}-windowsservercore-{base_image.split(':')[1]}" + arch_data = { + "download_url": binary["installer"]["link"], + "checksum": binary["installer"]["checksum"], + "copy_from": copy_from, + } + else: + arch_data[archHelper(binary["architecture"], os_family)] = { + "download_url": binary["package"]["link"], + "checksum": binary["package"]["checksum"], + } + + # Generate Dockerfile for each architecture + rendered_dockerfile = template.render( + base_image=base_image, + image_type=image_type, + java_version=openjdk_version, + version=version, + arch_data=arch_data, + os_family=os_family, + os=os_name, + ) + + # Save the rendered Dockerfile + with open( + os.path.join(output_directory, "Dockerfile"), "w" + ) as out_file: + out_file.write(rendered_dockerfile) + + # Copy entrypoint.sh to output directory + entrypoint_path = os.path.join( + "docker_templates", "scripts", f"entrypoint.{os_name}.sh" + ) + + if os.path.exists(entrypoint_path): + os.system( + f"cp {entrypoint_path} {os.path.join(output_directory, 'entrypoint.sh')}" + ) + + else: + continue + +print("Dockerfiles generated successfully!") diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..cb241183f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Jinja2==3.1.2 +PyYAML==6.0.1 +Requests==2.31.0 diff --git a/scripts/entrypoint.jammy.sh b/scripts/entrypoint.jammy.sh deleted file mode 120000 index ce5e34af9..000000000 --- a/scripts/entrypoint.jammy.sh +++ /dev/null @@ -1 +0,0 @@ -entrypoint.alpine.sh \ No newline at end of file diff --git a/test_generate_dockerfiles.py b/test_generate_dockerfiles.py new file mode 100644 index 000000000..5e523fd55 --- /dev/null +++ b/test_generate_dockerfiles.py @@ -0,0 +1,215 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import unittest +from unittest.mock import Mock, mock_open, patch + +from jinja2 import Environment, FileSystemLoader + +import generate_dockerfiles + + +class TestHelperFunctions(unittest.TestCase): + def test_archHelper(self): + test_data = [ + ("aarch64", "some-os", "aarch64|arm64"), + ("ppc64le", "some-os", "ppc64el|powerpc:common64"), + ("s390x", "some-os", "s390x|s390:64-bit"), + ("arm", "some-os", "armhf|arm"), + ("x64", "alpine-linux", "amd64|x86_64"), + ("x64", "ubuntu", "amd64|i386:x86-64"), + ("random-arch", "some-os", "random-arch"), + ] + + for arch, os_family, expected in test_data: + self.assertEqual(generate_dockerfiles.archHelper(arch, os_family), expected) + + def test_osFamilyHelper(self): + test_data = [ + ("ubuntu", "linux"), + ("centos", "linux"), + ("ubi9-minimal", "linux"), + ("nanoserver", "windows"), + ("servercore", "windows"), + ("random-os", "random-os"), + ] + + for os_name, expected in test_data: + self.assertEqual(generate_dockerfiles.osFamilyHelper(os_name), expected) + + @patch("requests.get") + def test_fetch_latest_release(self, mock_get): + # Mocking the request.get call + mock_response = Mock() + mock_response.raise_for_status.return_value = None + mock_response.json.return_value = [{"key": "value"}] + mock_get.return_value = mock_response + + url = "https://api.adoptium.net/v3/assets/feature_releases/some_version/ga?page=0&image_type=some_type&page_size=1&vendor=eclipse" + response = generate_dockerfiles.requests.get( + url, headers=generate_dockerfiles.headers + ) + data = response.json() + self.assertIn("key", data[0]) + self.assertEqual(data[0]["key"], "value") + + @patch("builtins.open", new_callable=mock_open, read_data="configurations: []") + def test_load_config(self, mock_file): + with open("config/hotspot.yml", "r") as file: + config = generate_dockerfiles.yaml.safe_load(file) + self.assertIn("configurations", config) + + +class TestJinjaRendering(unittest.TestCase): + def setUp(self): + # Setup the Jinja2 environment + self.env = Environment(loader=FileSystemLoader("docker_templates")) + + def test_armhf_ubuntu8_rendering(self): + template_name = "ubuntu.Dockerfile.j2" + template = self.env.get_template(template_name) + + arch_data = {} + + arch_data["armhf|arm"] = { + "download_url": "http://fake-url.com", + "checksum": "fake-checksum", + } + + # The context/variables to render the template + context = { + "architecture": "armhf|arm", + "os": "ubuntu", + "version": "8", + "arch_data": arch_data, + } + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "# Fixes libatomic.so.1: cannot open shared object file" + self.assertIn(expected_string, rendered_template) + + def test_version_checker(self): + template_name = "partials/version-check.j2" + template = self.env.get_template(template_name) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "&& echo javac --version && javac --version" + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "&& echo javac -version && javac -version" + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "&& echo javac --version && javac --version" + self.assertNotIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "&& echo javac -version && javac -version" + self.assertNotIn(expected_string, rendered_template) + + def test_version_checker_windows(self): + template_name = "partials/version-check-windows.j2" + template = self.env.get_template(template_name) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "Write-Host 'javac --version'; javac --version;" + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "Write-Host 'javac -version'; javac -version;" + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "Write-Host 'javac --version'; javac --version;" + self.assertNotIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = "Write-Host 'javac -version'; javac -version;" + self.assertNotIn(expected_string, rendered_template) + + def test_jdk11plus_jshell_cmd(self): + template_name = "partials/jshell.j2" + template = self.env.get_template(template_name) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "11", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "17", "image_type": "jre"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertNotIn(expected_string, rendered_template) + + with self.subTest(): + # The context/variables to render the template + context = {"version": "8", "image_type": "jdk"} + rendered_template = template.render(**context) + + # Expected string/partial in the rendered output + expected_string = 'CMD ["jshell"]' + self.assertNotIn(expected_string, rendered_template) + + +if __name__ == "__main__": + unittest.main() diff --git a/update_all.sh b/update_all.sh deleted file mode 100755 index 459fbfc36..000000000 --- a/update_all.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -set -o pipefail - -# shellcheck source=common_functions.sh -source ./common_functions.sh - -for ver in ${supported_versions} -do - # Remove any temporary files - rm -f hotspot_*_latest.sh - - echo "===============================================================================" - echo " " - echo " Writing Dockerfiles for Version ${ver} " - echo " " - echo "===============================================================================" - # Now generate the Dockerfiles for the official images. - ./update_multiarch.sh "${ver}" -done diff --git a/update_multiarch.sh b/update_multiarch.sh deleted file mode 100755 index 03c8001f4..000000000 --- a/update_multiarch.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Script for updating multiarch docker images for a specific openjdk version -set -o pipefail - -# Dockerfiles to be generated -version="9" -export root_dir="$PWD" - -source ./common_functions.sh -source ./dockerfile_functions.sh - -if [ -n "$1" ]; then - set_version "$1" -fi - -# Set the OSes that will be built on based on the current arch -set_arch_os - -# Iterate through all the Java versions for each of the supported packages, -# architectures and supported Operating Systems. -for vm in ${all_jvms} -do - for package in ${all_packages} - do - oses=$(parse_os_entry "${vm}") - for os in ${oses} - do - # Build = Release or Nightly - builds=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "Build:") - # Build Type = Full or Slim - btypes=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "Type:") - dir=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "Directory:") - osfamily=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "OS_Family:") - - for build in ${builds} - do - echo "Getting latest shasum info for [ ${version} ${vm} ${package} ${build} ]" - get_shasums "${version}" "${vm}" "${package}" "${build}" - # Source the generated shasums file to access the array - if [ -f "${vm}"_shasums_latest.sh ]; then - # shellcheck disable=SC1090 - source ./"${vm}"_shasums_latest.sh - else - continue; - fi - # Check if the VM is supported for the current arch - shasums="${package}"_"${vm}"_"${version}"_"${build}"_sums - sup=$(vm_supported_onarch "${vm}" "${shasums}") - if [ -z "${sup}" ]; then - continue; - fi - # Generate all the Dockerfiles for each of the builds and build types - for btype in ${btypes} - do - # file="${dir}/Dockerfile.${build}.${btype}" - # Reenable the line above if we ever start doing multi build types - file="${dir}/Dockerfile" - generate_dockerfile "${file}" "${package}" "${build}" "${btype}" "${osfamily}" "${os}" - # Copy the script to generate slim builds. - if [ "${btype}" = "slim" ]; then - if [ "${os}" == "windows" ]; then - cp slim-java.ps1 config/slim-java* "${dir}" - else - cp slim-java.sh config/slim-java* "${dir}" - fi - fi - done - done - done - done -done