This is an automated email from the ASF dual-hosted git repository.

zixuan pushed a commit to branch branch-as-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 971cade3ab43c43646fad697ae08e043522090a4
Author: Zixuan Liu <[email protected]>
AuthorDate: Mon Sep 23 16:11:27 2024 +0800

    [improve][build] Use eclipse-temurin:17 image instead of apt installation
    
    Signed-off-by: Zixuan Liu <[email protected]>
---
 docker/pulsar/Dockerfile | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/docker/pulsar/Dockerfile b/docker/pulsar/Dockerfile
index b899fb61828..03abded477e 100644
--- a/docker/pulsar/Dockerfile
+++ b/docker/pulsar/Dockerfile
@@ -50,6 +50,20 @@ RUN for SUBDIRECTORY in conf data download logs; do \
 # to create those log directories. This should be removed when Trino is 
removed.
 RUN chmod g+w /pulsar/trino
 
+FROM eclipse-temurin:17 as jre-build
+
+# Create a custom Java runtime
+RUN $JAVA_HOME/bin/jlink \
+         --add-modules ALL-MODULE-PATH \
+         --strip-debug \
+         --no-man-pages \
+         --no-header-files \
+         --compress=2 \
+         --output /javaruntime
+
+RUN echo networkaddress.cache.ttl=1 >> /javaruntime/conf/security/java.security
+RUN echo networkaddress.cache.negative.ttl=1 >> 
/javaruntime/conf/security/java.security
+
 ### Create 2nd stage from Ubuntu image
 ### and add OpenJDK and Python dependencies (for Pulsar functions)
 
@@ -68,26 +82,17 @@ RUN sed -i -e 
"s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-mirror://m
      && apt-get -y dist-upgrade \
      && apt-get -y install netcat dnsutils less procps iputils-ping \
                  curl ca-certificates wget apt-transport-https \
-     && apt-get -y install --no-install-recommends python3 python3-kazoo 
python3-pip
-
-# Install Eclipse Temurin Package
-RUN mkdir -p /etc/apt/keyrings \
-     && wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public 
| tee /etc/apt/keyrings/adoptium.asc \
-     && echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] 
https://packages.adoptium.net/artifactory/deb $(awk -F= 
'/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee 
/etc/apt/sources.list.d/adoptium.list \
-     && apt-get update \
-     && apt-get -y dist-upgrade \
-     && apt-get -y install temurin-17-jdk \
-     && export ARCH=$(uname -m | sed -r 's/aarch64/arm64/g' |  awk 
'!/arm64/{$0="amd64"}1') \
-     && echo networkaddress.cache.ttl=1 >> 
/usr/lib/jvm/temurin-17-jdk-$ARCH/conf/security/java.security \
-     && echo networkaddress.cache.negative.ttl=1 >> 
/usr/lib/jvm/temurin-17-jdk-$ARCH/conf/security/java.security
-
-# Cleanup apt
-RUN apt-get -y --purge autoremove \
+     && apt-get -y install --no-install-recommends python3 python3-kazoo 
python3-pip \
+     && apt-get -y --purge autoremove \
      && apt-get autoclean \
      && apt-get clean \
-     && rm -rf /var/lib/apt/lists/*
+     && rm -rf /var/lib/apt/lists/* \
+     && pip3 install pyyaml==6.0.1
 
-RUN pip3 install pyyaml==6.0.1
+# Copy Eclipse Temurin Package
+ENV JAVA_HOME=/opt/java/openjdk
+ENV PATH="$PATH:$JAVA_HOME/bin"
+COPY --from=jre-build /javaruntime $JAVA_HOME
 
 # Pulsar currently writes to the below directories, assuming the default 
configuration.
 # Note that number 4 is the reason that pulsar components need write access to 
the /pulsar directory.

Reply via email to