Skip to content

Commit c0aab49

Browse files
yaalsncoderzc
authored andcommitted
[fix][ci] Fix snappy-java native lib fails to load in x86 alpine (#22804)
(cherry picked from commit 7b8f4a9)
1 parent 66baa8d commit c0aab49

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docker/pulsar/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ RUN for SUBDIRECTORY in conf data download logs instances/deps packages-storage;
4848
RUN chmod -R g+rx /pulsar/bin
4949
RUN chmod -R o+rx /pulsar
5050

51+
# Enable snappy-java to use system lib
52+
RUN echo 'OPTS="$OPTS -Dorg.xerial.snappy.use.systemlib=true"' >> /pulsar/conf/bkenv.sh
53+
5154
### Create one stage to include JVM distribution
5255
FROM alpine AS jvm
5356

@@ -61,7 +64,16 @@ RUN /usr/lib/jvm/default-jvm/bin/jlink --add-modules ALL-MODULE-PATH --compress
6164
RUN echo networkaddress.cache.ttl=1 >> /opt/jvm/conf/security/java.security
6265
RUN echo networkaddress.cache.negative.ttl=1 >> /opt/jvm/conf/security/java.security
6366

67+
## Create one stage to include snappy-java native lib
68+
# Fix the issue when using snappy-java in x86 arch alpine
69+
# See https://github.com/xerial/snappy-java/issues/181 https://github.com/xerial/snappy-java/issues/579
70+
# We need to ensure that the version of the native library matches the version of snappy-java imported via Maven
71+
FROM alpine AS snappy-java
6472

73+
ARG SNAPPY_VERSION
74+
RUN apk add git alpine-sdk util-linux cmake autoconf automake libtool openjdk17 maven curl bash tar
75+
ENV JAVA_HOME=/usr
76+
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
6577
FROM apachepulsar/glibc-base:2.38 as glibc
6678

6779
## Create final stage from Alpine image
@@ -115,6 +127,8 @@ RUN apk add --allow-untrusted --force-overwrite /root/packages/glibc-*.apk
115127
COPY --from=jvm /opt/jvm /opt/jvm
116128
ENV JAVA_HOME=/opt/jvm
117129

130+
COPY --from=snappy-java /tmp/libsnappyjava.so /usr/lib/libsnappyjava.so
131+
118132
# The default is /pulsat/bin and cannot be written.
119133
ENV PULSAR_PID_DIR=/pulsar/logs
120134

docker/pulsar/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<args>
8383
<PULSAR_TARBALL>target/pulsar-server-distribution-${project.version}-bin.tar.gz</PULSAR_TARBALL>
8484
<PULSAR_CLIENT_PYTHON_VERSION>${pulsar.client.python.version}</PULSAR_CLIENT_PYTHON_VERSION>
85+
<SNAPPY_VERSION>${snappy.version}</SNAPPY_VERSION>
8586
</args>
8687
<contextDir>${project.basedir}</contextDir>
8788
<tags>

0 commit comments

Comments
 (0)