diff --git a/BUILD.md b/BUILD.md index 86eac4a..46a3301 100755 --- a/BUILD.md +++ b/BUILD.md @@ -116,4 +116,20 @@ If you are using Mac and openjdk7 (or higher), use the following option: $ make native LIBNAME=libsnappyjava.dylib +## Building with musl libc +This project now supports building with musl libc, which is commonly used in Alpine Linux. To build using musl: +1. Use the provided Alpine-based Dockerfile: +```bash +docker build -f docker/Dockerfile.alpine -t snappy-java-alpine . +docker run -it snappy-java-alpine sh +make +``` + +2. The build process will: +- Use musl libc instead of glibc +- Statically link required libraries +- Create a native library compatible with Alpine/musl systems + +The resulting library will be placed in: +`src/main/resources/org/xerial/snappy/native/Linux-musl/x86_64/libsnappyjava.so` diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 3b6119e..26821b8 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -1,16 +1,36 @@ FROM alpine:3.18 +# Set workspace directory +WORKDIR /work + +# Copy the project to the container +COPY . . + # Install build dependencies RUN apk add --no-cache \ + openjdk8 \ cmake \ make \ gcc \ g++ \ musl-dev \ - linux-headers + linux-headers \ + git \ + util-linux \ + bash \ + curl -# Set workspace directory -WORKDIR /work +# Install SBT +RUN curl -L "https://github.com/sbt/sbt/releases/download/v1.9.7/sbt-1.9.7.tgz" | tar xz -C /usr/local +ENV PATH="/usr/local/sbt/bin:${PATH}" -# Build the project +# Install python/pip +ENV PYTHONUNBUFFERED=1 +RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python +RUN python3 -m ensurepip +RUN pip3 install --no-cache --upgrade pip setuptools + +# Set Env Vars ENV CC=gcc CXX=g++ TARGET_OS=Linux-musl +ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk +ENV PATH="${JAVA_HOME}/bin:${PATH}" diff --git a/docker/README-musl.md b/docker/README-musl.md deleted file mode 100644 index 1d56e36..0000000 --- a/docker/README-musl.md +++ /dev/null @@ -1,22 +0,0 @@ -# Building with musl libc - -This project now supports building with musl libc, which is commonly used in Alpine Linux. To build using musl: - -1. Use the provided Alpine-based Dockerfile: -```bash -docker build -f docker/Dockerfile.alpine -t snappy-java-alpine . -``` - -2. The build process will: -- Use musl libc instead of glibc -- Statically link required libraries -- Create a native library compatible with Alpine/musl systems - -The resulting library will be placed in: -`src/main/resources/org/xerial/snappy/native/Linux-musl/x86_64/libsnappyjava.so` - -## Testing -To test the musl build: -```bash -docker run --rm snappy-java-alpine -cp target/snappy-java-*.jar org.xerial.snappy.SnappyLoader -``` \ No newline at end of file diff --git a/src/main/resources/org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so b/src/main/resources/org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so index c4fa5a4..fa18338 100755 Binary files a/src/main/resources/org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so and b/src/main/resources/org/xerial/snappy/native/Linux/aarch64/libsnappyjava.so differ