From 8bfe02afde3896b9b059d0f90753366fb938947c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=9Alizak?= Date: Thu, 9 Feb 2023 11:19:21 +0100 Subject: [PATCH] Add more mirrors Future-proof against Ubuntu codename update This approach works as long the following assumptions hold: - the location of `/etc/os-release` file does NOT change - the name of the UBUNTU_CODENAME environment variable does NOT change - `eclipse-temurin` still uses Ubuntu as it's base --- core/docker/Dockerfile | 8 ++++++++ core/docker/build.sh | 6 +++++- .../default/apt/sources.list.d/mirrors-amd64.sources | 6 ++++++ .../default/apt/sources.list.d/mirrors-arm64.sources | 6 ++++++ .../default/apt/sources.list.d/mirrors-ppc64le.sources | 7 +++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 core/docker/default/apt/sources.list.d/mirrors-amd64.sources create mode 100644 core/docker/default/apt/sources.list.d/mirrors-arm64.sources create mode 100644 core/docker/default/apt/sources.list.d/mirrors-ppc64le.sources diff --git a/core/docker/Dockerfile b/core/docker/Dockerfile index ec91f1094a72..16947114a48a 100644 --- a/core/docker/Dockerfile +++ b/core/docker/Dockerfile @@ -13,8 +13,12 @@ # FROM eclipse-temurin:17-jdk AS builder +COPY default/apt/sources.list.d /etc/apt/sources.list.d + RUN \ set -xeu && \ + . /etc/os-release && \ + sed -i "s/\${UBUNTU_CODENAME}/${UBUNTU_CODENAME}/g" /etc/apt/sources.list.d/* && \ 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 && \ @@ -24,8 +28,12 @@ RUN \ FROM eclipse-temurin:17-jdk +COPY default/apt/sources.list.d /etc/apt/sources.list.d + RUN \ set -xeu && \ + . /etc/os-release && \ + sed -i "s/\${UBUNTU_CODENAME}/${UBUNTU_CODENAME}/g" /etc/apt/sources.list.d/* && \ 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 && \ diff --git a/core/docker/build.sh b/core/docker/build.sh index ec9c64f2034f..63623d1de7dc 100755 --- a/core/docker/build.sh +++ b/core/docker/build.sh @@ -65,12 +65,15 @@ cp "$trino_client" "${WORK_DIR}/" tar -C "${WORK_DIR}" -xzf "${WORK_DIR}/trino-server-${TRINO_VERSION}.tar.gz" rm "${WORK_DIR}/trino-server-${TRINO_VERSION}.tar.gz" cp -R bin "${WORK_DIR}/trino-server-${TRINO_VERSION}" -cp -R default "${WORK_DIR}/" +mkdir -p "${WORK_DIR}/default" +cp -R default/etc "${WORK_DIR}/default/" TAG_PREFIX="trino:${TRINO_VERSION}" for arch in "${ARCHITECTURES[@]}"; do echo "🫙 Building the image for $arch" + mkdir -p "${WORK_DIR}/default/apt/sources.list.d" + cp "default/apt/sources.list.d/mirrors-$arch.sources" "${WORK_DIR}/default/apt/sources.list.d/" docker build \ "${WORK_DIR}" \ --pull \ @@ -78,6 +81,7 @@ for arch in "${ARCHITECTURES[@]}"; do -f Dockerfile \ -t "${TAG_PREFIX}-$arch" \ --build-arg "TRINO_VERSION=${TRINO_VERSION}" + rm -fr "${WORK_DIR}/default/apt/sources.list.d" done echo "🧹 Cleaning up the build context directory" diff --git a/core/docker/default/apt/sources.list.d/mirrors-amd64.sources b/core/docker/default/apt/sources.list.d/mirrors-amd64.sources new file mode 100644 index 000000000000..9fd0eeef7052 --- /dev/null +++ b/core/docker/default/apt/sources.list.d/mirrors-amd64.sources @@ -0,0 +1,6 @@ +Enabled: yes +Types: deb +URIs: https://mirrors.ocf.berkeley.edu/ubuntu/ https://mirror.kumi.systems/ubuntu/ +Suites: ${UBUNTU_CODENAME} ${UBUNTU_CODENAME}-updates ${UBUNTU_CODENAME}-backports ${UBUNTU_CODENAME}-security +Components: main restricted universe multiverse +Architectures: amd64 diff --git a/core/docker/default/apt/sources.list.d/mirrors-arm64.sources b/core/docker/default/apt/sources.list.d/mirrors-arm64.sources new file mode 100644 index 000000000000..3f1b0dd9c7f3 --- /dev/null +++ b/core/docker/default/apt/sources.list.d/mirrors-arm64.sources @@ -0,0 +1,6 @@ +Enabled: yes +Types: deb +URIs: https://mirrors.ocf.berkeley.edu/ubuntu-ports/ https://mirror.kumi.systems/ubuntu-ports/ +Suites: ${UBUNTU_CODENAME} ${UBUNTU_CODENAME}-updates ${UBUNTU_CODENAME}-backports ${UBUNTU_CODENAME}-security +Components: main restricted universe multiverse +Architectures: arm64 diff --git a/core/docker/default/apt/sources.list.d/mirrors-ppc64le.sources b/core/docker/default/apt/sources.list.d/mirrors-ppc64le.sources new file mode 100644 index 000000000000..4cc866de6b5c --- /dev/null +++ b/core/docker/default/apt/sources.list.d/mirrors-ppc64le.sources @@ -0,0 +1,7 @@ +Enabled: yes +Types: deb +URIs: https://mirrors.ocf.berkeley.edu/ubuntu-ports/ https://mirror.kumi.systems/ubuntu-ports/ +Suites: ${UBUNTU_CODENAME} ${UBUNTU_CODENAME}-updates ${UBUNTU_CODENAME}-backports ${UBUNTU_CODENAME}-security +Components: main restricted universe multiverse +# This is NOT a typo, Ubuntu calls "little endian" architecture "endian little" +Architectures: ppc64el