Skip to content

Commit 63c06b1

Browse files
Lewuatheelectrum
authored andcommitted
Build Docker image for arm64
The Docker images now have an `-amd64` or `-arm64` suffix. These can be combined into a single multi-arch image when pushed to a registry.
1 parent 00504d2 commit 63c06b1

File tree

6 files changed

+72
-17
lines changed

6 files changed

+72
-17
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
$RETRY bash -c './mvnw verify -B --strict-checksums -P ci -pl :trino-server-rpm || find core/trino-server-rpm/ -exec ls -ald {} +'
5555
- name: Clean Maven Output
5656
run: ./mvnw clean -pl '!:trino-server,!:trino-cli'
57+
- uses: docker/setup-qemu-action@v1
58+
with:
59+
platforms: arm64
5760
- name: Test Docker Image
5861
run: core/docker/build-local.sh
5962

File renamed without changes.

core/docker/arm64.dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
FROM centos:centos8
15+
16+
ENV JAVA_HOME /usr/lib/jvm/jre-11
17+
RUN \
18+
set -xeu && \
19+
yum -y -q install python3 java-11-openjdk-headless && \
20+
yum -q clean all && \
21+
rm -rf /var/cache/yum && \
22+
alternatives --set python /usr/bin/python3 && \
23+
groupadd trino --gid 1000 && \
24+
useradd trino --uid 1000 --gid 1000 && \
25+
mkdir -p /usr/lib/trino /data/trino && \
26+
chown -R "trino:trino" /usr/lib/trino /data/trino
27+
28+
ARG TRINO_VERSION
29+
COPY trino-cli-${TRINO_VERSION}-executable.jar /usr/bin/trino
30+
COPY --chown=trino:trino trino-server-${TRINO_VERSION} /usr/lib/trino
31+
COPY --chown=trino:trino default/etc /etc/trino
32+
33+
EXPOSE 8080
34+
USER trino:trino
35+
ENV LANG en_US.UTF-8
36+
CMD ["/usr/lib/trino/bin/run-trino"]

core/docker/build-local.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -euxo pipefail
3+
set -euo pipefail
44

55
SOURCE_DIR="../.."
66

@@ -24,11 +24,16 @@ cp ${SOURCE_DIR}/client/trino-cli/target/trino-cli-${TRINO_VERSION}-executable.j
2424

2525
CONTAINER="trino:${TRINO_VERSION}"
2626

27-
docker build ${WORK_DIR} --pull -f Dockerfile -t ${CONTAINER} --build-arg "TRINO_VERSION=${TRINO_VERSION}"
27+
docker build ${WORK_DIR} --pull --platform linux/amd64 -f amd64.dockerfile -t ${CONTAINER}-amd64 --build-arg "TRINO_VERSION=${TRINO_VERSION}"
28+
docker build ${WORK_DIR} --pull --platform linux/arm64 -f arm64.dockerfile -t ${CONTAINER}-arm64 --build-arg "TRINO_VERSION=${TRINO_VERSION}"
2829

2930
rm -r ${WORK_DIR}
3031

3132
# Source common testing functions
3233
. container-test.sh
3334

34-
test_container ${CONTAINER}
35+
test_container ${CONTAINER}-amd64 linux/amd64
36+
test_container ${CONTAINER}-arm64 linux/arm64
37+
38+
docker image inspect -f '🚀 Built {{.RepoTags}} {{.Id}}' ${CONTAINER}-amd64
39+
docker image inspect -f '🚀 Built {{.RepoTags}} {{.Id}}' ${CONTAINER}-arm64

core/docker/build-remote.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [[ $# -lt 1 ]]; then
55
exit 1
66
fi
77

8-
set -euxo pipefail
8+
set -euo pipefail
99

1010
# Retrieve the script directory.
1111
SCRIPT_DIR="${BASH_SOURCE%/*}"
@@ -27,11 +27,16 @@ chmod +x ${WORK_DIR}/trino-cli-${TRINO_VERSION}-executable.jar
2727

2828
CONTAINER="trino:${TRINO_VERSION}"
2929

30-
docker build ${WORK_DIR} --pull -f Dockerfile -t ${CONTAINER} --build-arg "TRINO_VERSION=${TRINO_VERSION}"
30+
docker build ${WORK_DIR} --pull --platform linux/amd64 -f amd64.dockerfile -t ${CONTAINER}-amd64 --build-arg "TRINO_VERSION=${TRINO_VERSION}"
31+
docker build ${WORK_DIR} --pull --platform linux/arm64 -f arm64.dockerfile -t ${CONTAINER}-arm64 --build-arg "TRINO_VERSION=${TRINO_VERSION}"
3132

3233
rm -r ${WORK_DIR}
3334

3435
# Source common testing functions
3536
. container-test.sh
3637

37-
test_container ${CONTAINER}
38+
test_container ${CONTAINER}-amd64 linux/amd64
39+
test_container ${CONTAINER}-arm64 linux/arm64
40+
41+
docker image inspect -f '🚀 Built {{.RepoTags}} {{.Id}}' ${CONTAINER}-amd64
42+
docker image inspect -f '🚀 Built {{.RepoTags}} {{.Id}}' ${CONTAINER}-arm64

core/docker/container-test.sh

100755100644
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#!/usr/bin/env bash
2-
3-
set -euxo pipefail
4-
5-
CONTAINER_ID=
6-
71
function cleanup {
82
if [[ ! -z ${CONTAINER_ID:-} ]]; then
93
docker stop "${CONTAINER_ID}"
@@ -14,35 +8,47 @@ function test_trino_starts {
148
local QUERY_PERIOD=5
159
local QUERY_RETRIES=30
1610

11+
CONTAINER_ID=
1712
trap cleanup EXIT
1813

1914
local CONTAINER_NAME=$1
20-
CONTAINER_ID=$(docker run -d --rm "${CONTAINER_NAME}")
15+
local PLATFORM=$2
16+
CONTAINER_ID=$(docker run -d --rm --platform ${PLATFORM} "${CONTAINER_NAME}")
2117

2218
set +e
2319
I=0
24-
until RESULT=$(docker exec "${CONTAINER_ID}" trino --execute "SELECT 'success'"); do
20+
until RESULT=$(docker exec "${CONTAINER_ID}" trino --execute "SELECT 'success'" 2>/dev/null)
21+
do
2522
if [[ $((I++)) -ge ${QUERY_RETRIES} ]]; then
26-
echo "Too many retries waiting for Trino to start."
23+
echo "🚨 Too many retries waiting for Trino to start"
2724
break
2825
fi
2926
sleep ${QUERY_PERIOD}
3027
done
3128
set -e
3229

30+
cleanup
31+
trap - EXIT
32+
3333
# Return proper exit code.
3434
[[ ${RESULT} == '"success"' ]]
3535
}
3636

3737
function test_javahome {
3838
local CONTAINER_NAME=$1
39+
local PLATFORM=$2
3940
# Check if JAVA_HOME works
40-
docker run --rm "${CONTAINER_NAME}" /bin/bash -c '$JAVA_HOME/bin/java -version' &> /dev/null
41+
docker run --rm --platform ${PLATFORM} "${CONTAINER_NAME}" \
42+
/bin/bash -c '$JAVA_HOME/bin/java -version' &> /dev/null
4143

4244
[[ "$?" == "0" ]]
4345
}
4446

4547
function test_container {
4648
local CONTAINER_NAME=$1
47-
test_javahome ${CONTAINER_NAME} && test_trino_starts ${CONTAINER_NAME}
49+
local PLATFORM=$2
50+
echo "🐢 Validating ${CONTAINER_NAME} on platform ${PLATFORM}..."
51+
test_javahome ${CONTAINER_NAME} ${PLATFORM}
52+
test_trino_starts ${CONTAINER_NAME} ${PLATFORM}
53+
echo "🎉 Validated ${CONTAINER_NAME} on platform ${PLATFORM}"
4854
}

0 commit comments

Comments
 (0)