Files
Stirling-PDF/Dockerfile.fat
Ludy87 e6a27e8143 Limit build matrix and update LibreOffice version
Temporarily restricts the build workflow to only use Dockerfile.fat and updates the LibreOffice version in Dockerfile.fat from 25.8.2 to 25.2.6 for aarch64. This may be for troubleshooting or compatibility purposes.
2025-11-12 14:22:00 +01:00

162 lines
5.4 KiB
Docker

# Build the application
FROM gradle:8.14-jdk21 AS build
COPY build.gradle .
COPY settings.gradle .
COPY gradlew .
COPY gradle gradle/
COPY app/core/build.gradle core/.
COPY app/common/build.gradle common/.
COPY app/proprietary/build.gradle proprietary/.
RUN ./gradlew build -x spotlessApply -x spotlessCheck -x test -x sonarqube || return 0
# Set the working directory
WORKDIR /app
# Copy the entire project to the working directory
COPY . .
# Build the application with DISABLE_ADDITIONAL_FEATURES=false
ENV DISABLE_ADDITIONAL_FEATURES=false \
STIRLING_PDF_DESKTOP_UI=false
RUN ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube
# Main stage
FROM alpine:3.22.2@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412
ADD https://download.documentfoundation.org/libreoffice/stable/25.2.6/deb/aarch64/LibreOffice_25.2.6_Linux_aarch64_deb.tar.gz /tmp/lo.tar.gz
RUN mkdir -p /opt/libreoffice && \
tar -xzf /tmp/lo.tar.gz -C /opt/libreoffice --strip-components=1 && \
rm -f /tmp/lo.tar.gz && \
ln -sf /opt/libreoffice/program/soffice /usr/bin/soffice.bin && \
chmod 755 /usr/bin/soffice.bin
# Copy necessary files
COPY scripts /scripts
COPY app/core/src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto/
# first /app directory is for the build stage, second is for the final image
COPY --from=build /app/app/core/build/libs/*.jar app.jar
ARG VERSION_TAG
# Set Environment Variables
ENV DISABLE_ADDITIONAL_FEATURES=true \
VERSION_TAG=$VERSION_TAG \
JAVA_BASE_OPTS="-XX:+UnlockExperimentalVMOptions -XX:MaxRAMPercentage=75 -XX:InitiatingHeapOccupancyPercent=20 -XX:+G1PeriodicGCInvokesConcurrent -XX:G1PeriodicGCInterval=10000 -XX:+UseStringDeduplication -XX:G1PeriodicGCSystemLoadThreshold=70" \
JAVA_CUSTOM_OPTS="" \
HOME=/home/stirlingpdfuser \
PUID=1000 \
PGID=1000 \
UMASK=022 \
FAT_DOCKER=true \
INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false \
PYTHONPATH=/opt/libreoffice/program:/opt/venv/lib/python3.12/site-packages \
UNO_PATH=/opt/libreoffice/program \
URE_BOOTSTRAP=file:///opt/libreoffice/program/fundamentalrc \
PATH=$PATH:/opt/venv/bin \
STIRLING_TEMPFILES_DIRECTORY=/tmp/stirling-pdf \
TMPDIR=/tmp/stirling-pdf \
TEMP=/tmp/stirling-pdf \
TMP=/tmp/stirling-pdf
# JDK for app
RUN printf '%s\n' \
'https://dl-3.alpinelinux.org/alpine/edge/main' \
'https://dl-3.alpinelinux.org/alpine/edge/community' \
'https://dl-3.alpinelinux.org/alpine/edge/testing' \
> /etc/apk/repositories
# Bash + repositories
RUN apk add --no-cache bash && \
ln -sf /bin/bash /bin/sh
RUN --mount=type=cache,target=/var/cache/apk \
apk upgrade --no-cache -a
RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache \
ca-certificates \
tzdata \
tini \
bash \
curl \
shadow \
su-exec \
openssl \
openssl-dev \
openjdk21-jre
RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache \
ffmpeg \
# Doc conversion
gcompat \
libc6-compat \
unpaper \
poppler-utils \
icu-libs \
icu-dev \
libstdc++
# RUN --mount=type=cache,target=/var/cache/apk \
# apk add --no-cache \
# libreoffice
RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache \
# OCR MY PDF (unpaper for descew and other advanced featues)
tesseract-ocr-data-eng \
tesseract-ocr-data-chi_sim \
tesseract-ocr-data-deu \
tesseract-ocr-data-fra \
tesseract-ocr-data-por
RUN --mount=type=cache,target=/var/cache/apk \
apk add --no-cache \
unpaper \
font-terminus font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra font-liberation font-linux-libertine font-urw-base35 \
# CV / Python
py3-opencv \
python3 \
ocrmypdf \
py3-pip \
py3-pillow \
py3-pdf2image
RUN --mount=type=cache,target=/var/cache/apk \
# Calibre (musl-native) + QtWebEngine Runtime
apk add --no-cache calibre && \
# Calibre fixes
apk fix --no-cache calibre
RUN python3 -m venv /opt/venv && \
/opt/venv/bin/pip install --no-cache-dir --upgrade pip setuptools && \
/opt/venv/bin/pip install --no-cache-dir --upgrade unoserver weasyprint && \
ln -s /opt/libreoffice/program/uno.py /opt/venv/lib/python3.12/site-packages/ && \
ln -s /opt/libreoffice/program/unohelper.py /opt/venv/lib/python3.12/site-packages/ && \
ln -s /opt/libreoffice/program /opt/venv/lib/python3.12/site-packages/LibreOffice && \
mv /usr/share/tessdata /usr/share/tessdata-original && \
mkdir -p $HOME /configs /logs /customFiles /pipeline/watchedFolders /pipeline/finishedFolders /tmp/stirling-pdf && \
# Configure URW Base 35 fonts
ln -s /usr/share/fontconfig/conf.avail/69-urw-*.conf /etc/fonts/conf.d/ && \
fc-cache -f -v && \
chmod +x /scripts/* && \
# User permissions
addgroup -S stirlingpdfgroup && adduser -S stirlingpdfuser -G stirlingpdfgroup && \
chown -R stirlingpdfuser:stirlingpdfgroup \
$HOME \
/scripts \
/usr/share/fonts/opentype/noto \
/configs \
/customFiles \
/pipeline \
/tmp/stirling-pdf \
/app.jar && \
# chmod 755 /usr/bin/soffice.bin && \
ln -sf /bin/busybox /bin/sh
EXPOSE 8080/tcp
# Set user and run command
ENTRYPOINT ["tini", "--", "/scripts/init.sh"]
CMD ["sh", "-c", "java -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/tmp/stirling-pdf -jar /app.jar & /opt/venv/bin/unoserver --port 2003 --interface 127.0.0.1"]