fix: dockerfile building

This commit is contained in:
Samuel Fernandes 2025-01-17 20:37:20 +00:00
parent 0dc3e64353
commit 38a20ffc19
No known key found for this signature in database
GPG Key ID: C74A5164FE13D9B6
4 changed files with 40 additions and 26 deletions

View File

@ -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`

View File

@ -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}"

View File

@ -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
```