Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions core/docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail
set -xeuo pipefail

usage() {
cat <<EOF 1>&2
Expand All @@ -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"
Expand All @@ -28,6 +36,9 @@ while getopts ":a:h:r:" o; do
usage
exit 0
;;
j)
JDK_VERSION="${OPTARG}"
;;
*)
usage
exit 1
Expand All @@ -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&lts=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
Expand Down Expand Up @@ -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
Expand All @@ -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}"
Expand Down