Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24
24.0.2+12
33 changes: 25 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,48 @@

# syntax=docker/dockerfile:1
ARG TRINO_GATEWAY_BASE_IMAGE
FROM ${TRINO_GATEWAY_BASE_IMAGE} AS jdk-download
ARG TRINO_GATEWAY_BUILD_IMAGE

FROM ${TRINO_GATEWAY_BUILD_IMAGE} AS jdk-download
ARG JDK_DOWNLOAD_LINK
ARG JDK_VERSION
ENV JAVA_HOME="/usr/lib/jvm/jdk-${JDK_VERSION}"
ARG JDK_RELEASE_NAME
ENV JAVA_HOME="/usr/lib/jvm/jdk-${JDK_RELEASE_NAME}"

RUN \
set -xeuo pipefail && \
microdnf install -y tar gzip && \
dnf install -y tar gzip && \
# Install JDK from the provided archive link \
echo "Downloading JDK from ${JDK_DOWNLOAD_LINK}" && \
mkdir -p "${JAVA_HOME}" && \
curl -#LfS "${JDK_DOWNLOAD_LINK}" | tar -zx --strip 1 -C "${JAVA_HOME}"

FROM ${TRINO_GATEWAY_BUILD_IMAGE} AS packages

RUN \
set -xeuo pipefail && \
mkdir -p /tmp/overlay/usr/libexec/ && \
touch /tmp/overlay/usr/libexec/grepconf.sh && \
chmod +x /tmp/overlay/usr/libexec/grepconf.sh && \
dnf update -y && \
dnf install --installroot /tmp/overlay --setopt install_weak_deps=false --nodocs -y \
less \
zlib `#required by java` \
curl-minimal grep `# required by health-check` \
shadow-utils `# required by useradd` \
tar `# required to support kubectl cp` && \
rm -rf /tmp/overlay/var/cache/*

FROM ${TRINO_GATEWAY_BASE_IMAGE}
WORKDIR /usr/lib/trino-gateway

ARG JDK_VERSION
ENV JAVA_HOME="/usr/lib/jvm/jdk-${JDK_VERSION}"
ARG JDK_RELEASE_NAME
ENV JAVA_HOME="/usr/lib/jvm/jdk-${JDK_RELEASE_NAME}"
ENV PATH=$PATH:$JAVA_HOME/bin
COPY --from=jdk-download $JAVA_HOME $JAVA_HOME
COPY --from=packages /tmp/overlay /

RUN \
set -xeu && \
microdnf update -y && \
microdnf install -y tar less shadow-utils && \
groupadd trino --gid 1000 && \
useradd trino --uid 1000 --gid 1000 --create-home && \
mkdir -p /usr/lib/trino-gateway /etc/trino-gateway && \
Expand Down
33 changes: 12 additions & 21 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SOURCE_DIR="${SCRIPT_DIR}/.."

ARCHITECTURES=(amd64 arm64 ppc64le)
TRINO_GATEWAY_VERSION=
JDK_VERSION=$(cat "${SOURCE_DIR}/.java-version")
JDK_RELEASE_NAME=$(cat "${SOURCE_DIR}/.java-version")
# necessary to allow version parsing from the pom file
MVNW_VERBOSE=false

Expand All @@ -39,7 +39,7 @@ while getopts ":a:h:r:j:" o; do
exit 0
;;
j)
JDK_VERSION="${OPTARG}"
JDK_RELEASE_NAME="${OPTARG}"
;;
*)
usage
Expand All @@ -61,29 +61,18 @@ function check_environment() {
}

function temurin_jdk_link() {
JDK_VERSION="${1}"
JDK_RELEASE_NAME="${1}"
ARCH="${2}"

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
fi

if ! RELEASE_NAME=$(echo "$result" | jq -er '.releases[]' | grep "${JDK_VERSION}" | head -n 1); then
echo >&2 "Failed to determine release name: ${RELEASE_NAME}"
exit 1
fi

case "${ARCH}" in
arm64)
echo "https://api.adoptium.net/v3/binary/version/${RELEASE_NAME}/linux/aarch64/jdk/hotspot/normal/eclipse?project=jdk"
echo "https://api.adoptium.net/v3/binary/version/${JDK_RELEASE_NAME}/linux/aarch64/jdk/hotspot/normal/eclipse?project=jdk"
;;
amd64)
echo "https://api.adoptium.net/v3/binary/version/${RELEASE_NAME}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk"
echo "https://api.adoptium.net/v3/binary/version/${JDK_RELEASE_NAME}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk"
;;
ppc64le)
echo "https://api.adoptium.net/v3/binary/version/${RELEASE_NAME}/linux/ppc64le/jdk/hotspot/normal/eclipse?project=jdk"
echo "https://api.adoptium.net/v3/binary/version/${JDK_RELEASE_NAME}/linux/ppc64le/jdk/hotspot/normal/eclipse?project=jdk"
;;
*)
echo "${ARCH} is not supported for Docker image"
Expand Down Expand Up @@ -118,17 +107,19 @@ TAG_PREFIX="trino-gateway:${TRINO_GATEWAY_VERSION}"
#version file is used by the Helm chart test
echo "${TRINO_GATEWAY_VERSION}" > "${SOURCE_DIR}"/trino-gateway-version.txt

TRINO_GATEWAY_BASE_IMAGE=${TRINO_GATEWAY_BASE_IMAGE:-'registry.access.redhat.com/ubi9/ubi-minimal:latest'}
TRINO_GATEWAY_BASE_IMAGE=${TRINO_GATEWAY_BASE_IMAGE:-'registry.access.redhat.com/ubi10/ubi-micro:latest'}
TRINO_GATEWAY_BUILD_IMAGE=${TRINO_GATEWAY_BUILD_IMAGE:-'registry.access.redhat.com/ubi10/ubi:latest'}

for arch in "${ARCHITECTURES[@]}"; do
echo "🫙 Building the image for $arch with JDK ${JDK_VERSION}"
echo "🫙 Building the image for $arch with Temurin JDK release ${JDK_RELEASE_NAME}"
DOCKER_BUILDKIT=1 \
docker build \
"${WORK_DIR}" \
--pull \
--build-arg JDK_VERSION="${JDK_VERSION}" \
--build-arg JDK_DOWNLOAD_LINK="$(temurin_jdk_link "${JDK_VERSION}" "${arch}")" \
--build-arg JDK_RELEASE_NAME="${JDK_RELEASE_NAME}" \
--build-arg JDK_DOWNLOAD_LINK="$(temurin_jdk_link "jdk-${JDK_RELEASE_NAME}" "${arch}")" \
--build-arg TRINO_GATEWAY_BASE_IMAGE="${TRINO_GATEWAY_BASE_IMAGE}" \
--build-arg TRINO_GATEWAY_BUILD_IMAGE="${TRINO_GATEWAY_BUILD_IMAGE}" \
--platform "linux/$arch" \
-f Dockerfile \
-t "${TAG_PREFIX}-$arch"
Expand Down
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<air.check.skip-pmd>true</air.check.skip-pmd>
<air.modernizer.java-version>8</air.modernizer.java-version>
<air.release.preparation-goals>clean verify -DskipTests</air.release.preparation-goals>

<dep.jetty.version>12.0.25</dep.jetty.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -76,7 +78,19 @@
<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
<version>1.10</version>
<version>1.12</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>

<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.2.4</version>
</dependency>

<dependency>
Expand Down