Skip to content
Closed
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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ jobs:
- uses: docker/setup-qemu-action@v2
with:
platforms: arm64,ppc64le
- name: Set up Docker Buildx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not well-versed in buildx.
if you want me to continue the review of this PR, I would recommend splitting this out to a follow-up

uses: docker/setup-buildx-action@v2
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v2
- name: Test Docker Image
run: core/docker/build.sh
run: core/docker/build.sh -c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some issues with stability of Ubuntu repositories have surfaced lately.
Our Dockerfile tries to update packages in the base Ubuntu image, and
when that fails, the entire maven-checks job fails.

Updates are not necessary (per Docker's philosophy, updates to the base image should be part of base image lifecycle), but we install new stuff too.

We can use layers from the latest trino image to avoid running
these updates.

We already have some retries

echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "15";' > /etc/apt/apt.conf.d/80-timeouts && \

are these not sufficient?
what can we do to make them sufficient?

This change may get CI working, but we cannot rely on that for automated releases (once we have them), so would be nice to have some more self-contained solution

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this means CI won't see any updates to eclipse-temurin:17-jdk image only until we do a release.
So if eclipse-temurin:17-jdk updates affects us in any way, we won't know about that until our users know about that.

- name: Remove Trino from local Maven repo to avoid caching it
# Avoid caching artifacts built in this job, cache should only include dependencies
if: steps.cache.outputs.cache-hit != 'true'
Expand Down
28 changes: 2 additions & 26 deletions core/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM eclipse-temurin:17-jdk AS builder

RUN \
set -xeu && \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "15";' > /etc/apt/apt.conf.d/80-timeouts && \
apt-get update -q && \
apt-get install -y -q git gcc make && \
git clone https://github.com/airlift/jvmkill /tmp/jvmkill && \
make -C /tmp/jvmkill

FROM eclipse-temurin:17-jdk

RUN \
set -xeu && \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "15";' > /etc/apt/apt.conf.d/80-timeouts && \
apt-get update -q && \
apt-get install -y -q less python3 curl && \
rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
groupadd trino --gid 1000 && \
useradd trino --uid 1000 --gid 1000 --create-home && \
mkdir -p /usr/lib/trino /data/trino && \
chown -R "trino:trino" /usr/lib/trino /data/trino
ARG TRINO_VERSION
FROM trino-base:${TRINO_VERSION}-${TARGETARCH}

ARG TRINO_VERSION
COPY trino-cli-${TRINO_VERSION}-executable.jar /usr/bin/trino
COPY --chown=trino:trino trino-server-${TRINO_VERSION} /usr/lib/trino
COPY --chown=trino:trino default/etc /etc/trino
COPY --chown=trino:trino --from=builder /tmp/jvmkill/libjvmkill.so /usr/lib/trino/bin

EXPOSE 8080
USER trino:trino
Expand Down
40 changes: 40 additions & 0 deletions core/docker/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# 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
#
# http://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.
#
FROM eclipse-temurin:17-jdk AS builder

RUN \
set -xeu && \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "15";' > /etc/apt/apt.conf.d/80-timeouts && \
apt-get update -q && \
apt-get install -y -q git gcc make && \
git clone https://github.com/airlift/jvmkill /tmp/jvmkill && \
make -C /tmp/jvmkill

FROM eclipse-temurin:17-jdk

RUN \
set -xeu && \
echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries && \
echo 'Acquire::http::Timeout "15";' > /etc/apt/apt.conf.d/80-timeouts && \
apt-get update -q && \
apt-get install -y -q less python3 curl && \
rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
groupadd trino --gid 1000 && \
useradd trino --uid 1000 --gid 1000 --create-home && \
mkdir -p /usr/lib/trino /data/trino && \
chown -R "trino:trino" /usr/lib/trino /data/trino

COPY --chown=trino:trino --from=builder /tmp/jvmkill/libjvmkill.so /usr/lib/trino/bin/libjvmkill.so
50 changes: 39 additions & 11 deletions core/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@ set -euo pipefail

usage() {
cat <<EOF 1>&2
Usage: $0 [-h] [-a <ARCHITECTURES>] [-r <VERSION>]
Usage: $0 [-h] [-a <ARCHITECTURES>] [-r <VERSION>] [-c]
Builds the Trino Docker image

-h Display help
-a Build the specified comma-separated architectures, defaults to amd64,arm64
-a Build the specified comma-separated architectures, defaults to: amd64,arm64,ppc64le
-r Build the specified Trino release version, downloads all required artifacts
-c Use Docker build cache
EOF
}

ARCHITECTURES=(amd64 arm64 ppc64le)
TRINO_VERSION=
BUILD_CACHE=

while getopts ":a:h:r:" o; do
while getopts ":a:h:r:c" o; do
case "${o}" in
a)
IFS=, read -ra ARCHITECTURES <<< "$OPTARG"
;;
r)
TRINO_VERSION=${OPTARG}
;;
c)
BUILD_CACHE="type=gha"
;;
h)
usage
exit 0
Expand Down Expand Up @@ -67,17 +72,40 @@ rm "${WORK_DIR}/trino-server-${TRINO_VERSION}.tar.gz"
cp -R bin "${WORK_DIR}/trino-server-${TRINO_VERSION}"
cp -R default "${WORK_DIR}/"

# Prepare an empty build context for base image to speed up context copying
BASE_WORK_DIR="$(mktemp -d)"

BASE_PREFIX="trino-base:${TRINO_VERSION}"
TAG_PREFIX="trino:${TRINO_VERSION}"

echo "👷 Docker buildx builders available:"
docker buildx ls

for arch in "${ARCHITECTURES[@]}"; do
echo "🫙 Building the image for $arch"
docker build \
"${WORK_DIR}" \
--pull \
--platform "linux/$arch" \
-f Dockerfile \
-t "${TAG_PREFIX}-$arch" \
--build-arg "TRINO_VERSION=${TRINO_VERSION}"
echo "🫙 Building the base image for $arch"
BASE_BUILD_OPTIONS=(
${BASE_WORK_DIR}
--platform "linux/$arch"
--load
--tag "${BASE_PREFIX}-$arch"
-f base.Dockerfile
)
if [ -n "${BUILD_CACHE}" ]; then
echo "🎯 Using Docker build cache"
SCOPE="${GITHUB_REF_NAME:-$( git rev-parse --short HEAD: )}-${arch}"
BASE_BUILD_OPTIONS+=(--cache-from "${BUILD_CACHE},scope=${SCOPE}" --cache-to "${BUILD_CACHE},scope=${SCOPE},mode=max")
else
BASE_BUILD_OPTIONS+=(--pull)
fi
docker buildx build "${BASE_BUILD_OPTIONS[@]}"

echo "🫙 Building the main image for $arch"
DOCKER_BUILDKIT=1 docker build \
"${WORK_DIR}" \
--platform "linux/$arch" \
-f Dockerfile \
-t "${TAG_PREFIX}-$arch" \
--build-arg "TRINO_VERSION=${TRINO_VERSION}"
done

echo "🧹 Cleaning up the build context directory"
Expand Down