diff --git a/core/docker/build.sh b/core/docker/build.sh index 8d1e1f236516..a41106bf1a3e 100755 --- a/core/docker/build.sh +++ b/core/docker/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail +set -xeuo pipefail usage() { cat <&2 @@ -10,13 +10,21 @@ Builds the Trino Docker image -h Display help -a Build the specified comma-separated architectures, defaults to amd64,arm64,ppc64le -r Build the specified Trino release version, downloads all required artifacts +-j Build the Trino release with specified Temurin JDK release EOF } +# Retrieve the script directory. +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "${SCRIPT_DIR}" || exit 2 + +SOURCE_DIR="${SCRIPT_DIR}/../.." + ARCHITECTURES=(amd64 arm64 ppc64le) TRINO_VERSION= +JDK_VERSION=$(cat "${SOURCE_DIR}/.java-version") -while getopts ":a:h:r:" o; do +while getopts ":a:h:r:j:" o; do case "${o}" in a) IFS=, read -ra ARCHITECTURES <<< "$OPTARG" @@ -28,6 +36,9 @@ while getopts ":a:h:r:" o; do usage exit 0 ;; + j) + JDK_VERSION="${OPTARG}" + ;; *) usage exit 1 @@ -36,13 +47,11 @@ while getopts ":a:h:r:" o; do done shift $((OPTIND - 1)) -SOURCE_DIR="../.." - function temurin_jdk_link() { local JDK_VERSION="${1}" local ARCH="${2}" - versionsUrl="https://api.adoptium.net/v3/info/release_names?heap_size=normal&image_type=jdk<s=true&os=linux&page=0&page_size=20&project=jdk&release_type=ga&semver=false&sort_method=DEFAULT&sort_order=ASC&vendor=eclipse&version=%28${JDK_VERSION}%2C%5D" + versionsUrl="https://api.adoptium.net/v3/info/release_names?heap_size=normal&image_type=jdk&os=linux&page=0&page_size=20&project=jdk&release_type=ga&semver=false&sort_method=DEFAULT&sort_order=ASC&vendor=eclipse&version=%28${JDK_VERSION}%2C%5D" if ! result=$(curl -fLs "$versionsUrl" -H 'accept: application/json'); then echo >&2 "Failed to fetch release names for JDK version [${JDK_VERSION}, ) from Temurin API : $result" exit 1 @@ -70,10 +79,6 @@ function temurin_jdk_link() { esac } -# Retrieve the script directory. -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -cd "${SCRIPT_DIR}" || exit 2 - if [ -n "$TRINO_VERSION" ]; then echo "🎣 Downloading server and client artifacts for release version ${TRINO_VERSION}" for artifactId in io.trino:trino-server:"${TRINO_VERSION}":tar.gz io.trino:trino-cli:"${TRINO_VERSION}":jar:executable; do @@ -100,7 +105,6 @@ cp -R bin "${WORK_DIR}/trino-server-${TRINO_VERSION}" cp -R default "${WORK_DIR}/" TAG_PREFIX="trino:${TRINO_VERSION}" -JDK_VERSION=$(cat "${SOURCE_DIR}/.java-version") for arch in "${ARCHITECTURES[@]}"; do echo "🫙 Building the image for $arch with JDK ${JDK_VERSION}"