Skip to content

Commit

Permalink
[improve][build] Use jlink to custom Java runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan Liu <[email protected]>
  • Loading branch information
nodece committed May 29, 2024
1 parent 8da4484 commit 43cf4cf
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions docker/pulsar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ RUN for SUBDIRECTORY in conf data download logs; do \
# to create those log directories. This should be removed when presto is removed.
RUN chmod g+w /pulsar/lib/presto

FROM eclipse-temurin:11 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)

Expand All @@ -72,15 +86,10 @@ RUN sed -i -e "s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-http://arc
#If not upgraded, it will affect the installation of grpcio.
RUN python3 -m pip install --upgrade 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-11-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-11-jdk-$ARCH/conf/security/java.security
# Copy Eclipse Temurin Package
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

# Cleanup apt
RUN apt-get -y --purge autoremove \
Expand Down

0 comments on commit 43cf4cf

Please sign in to comment.