This is an automated email from the ASF dual-hosted git repository.
zhaocong pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new c0aab493aaf [fix][ci] Fix snappy-java native lib fails to load in x86
alpine (#22804)
c0aab493aaf is described below
commit c0aab493aafa5386dbf93c0b58a66a666aeba17a
Author: Lishen Yao <[email protected]>
AuthorDate: Mon Jun 3 11:07:18 2024 +0900
[fix][ci] Fix snappy-java native lib fails to load in x86 alpine (#22804)
(cherry picked from commit 7b8f4a9159cf9e985b4d45f98c20f50674c701db)
---
docker/pulsar/Dockerfile | 14 ++++++++++++++
docker/pulsar/pom.xml | 1 +
2 files changed, 15 insertions(+)
diff --git a/docker/pulsar/Dockerfile b/docker/pulsar/Dockerfile
index 9d46dc97374..f3fea0e1e9d 100644
--- a/docker/pulsar/Dockerfile
+++ b/docker/pulsar/Dockerfile
@@ -48,6 +48,9 @@ RUN for SUBDIRECTORY in conf data download logs
instances/deps packages-storage;
RUN chmod -R g+rx /pulsar/bin
RUN chmod -R o+rx /pulsar
+# Enable snappy-java to use system lib
+RUN echo 'OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"' >>
/pulsar/conf/bkenv.sh
+
### Create one stage to include JVM distribution
FROM alpine AS jvm
@@ -61,7 +64,16 @@ RUN /usr/lib/jvm/default-jvm/bin/jlink --add-modules
ALL-MODULE-PATH --compress
RUN echo networkaddress.cache.ttl=1 >> /opt/jvm/conf/security/java.security
RUN echo networkaddress.cache.negative.ttl=1 >>
/opt/jvm/conf/security/java.security
+## Create one stage to include snappy-java native lib
+# Fix the issue when using snappy-java in x86 arch alpine
+# See https://github.com/xerial/snappy-java/issues/181
https://github.com/xerial/snappy-java/issues/579
+# We need to ensure that the version of the native library matches the version
of snappy-java imported via Maven
+FROM alpine AS snappy-java
+ARG SNAPPY_VERSION
+RUN apk add git alpine-sdk util-linux cmake autoconf automake libtool
openjdk17 maven curl bash tar
+ENV JAVA_HOME=/usr
+RUN curl -Ls
https://github.com/xerial/snappy-java/archive/refs/tags/v$SNAPPY_VERSION.tar.gz
| tar zxf - && cd snappy-java-$SNAPPY_VERSION && make clean-native native
FROM apachepulsar/glibc-base:2.38 as glibc
## Create final stage from Alpine image
@@ -115,6 +127,8 @@ RUN apk add --allow-untrusted --force-overwrite
/root/packages/glibc-*.apk
COPY --from=jvm /opt/jvm /opt/jvm
ENV JAVA_HOME=/opt/jvm
+COPY --from=snappy-java /tmp/libsnappyjava.so /usr/lib/libsnappyjava.so
+
# The default is /pulsat/bin and cannot be written.
ENV PULSAR_PID_DIR=/pulsar/logs
diff --git a/docker/pulsar/pom.xml b/docker/pulsar/pom.xml
index 88bb202445e..072d0fa87b1 100644
--- a/docker/pulsar/pom.xml
+++ b/docker/pulsar/pom.xml
@@ -82,6 +82,7 @@
<args>
<PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</PULSAR_TARBALL>
<PULSAR_CLIENT_PYTHON_VERSION>${pulsar.client.python.version}</PULSAR_CLIENT_PYTHON_VERSION>
+ <SNAPPY_VERSION>${snappy.version}</SNAPPY_VERSION>
</args>
<contextDir>${project.basedir}</contextDir>
<tags>