2024-06-01 13:38:10 +02:00
|
|
|
# Build the application
|
2025-01-02 15:55:42 +01:00
|
|
|
FROM gradle:8.12-jdk17 AS build
|
2024-06-01 13:38:10 +02:00
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy the entire project to the working directory
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Build the application with DOCKER_ENABLE_SECURITY=false
|
|
|
|
RUN DOCKER_ENABLE_SECURITY=true \
|
2025-02-18 12:57:56 +01:00
|
|
|
STIRLING_PDF_DESKTOP_UI=false \
|
2024-08-20 17:17:54 +02:00
|
|
|
./gradlew clean build
|
2024-06-01 13:38:10 +02:00
|
|
|
|
|
|
|
# Main stage
|
2025-02-17 11:21:40 +01:00
|
|
|
FROM alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c
|
2024-06-01 13:38:10 +02:00
|
|
|
|
|
|
|
# Copy necessary files
|
|
|
|
COPY scripts /scripts
|
|
|
|
COPY pipeline /pipeline
|
|
|
|
COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto/
|
|
|
|
COPY --from=build /app/build/libs/*.jar app.jar
|
|
|
|
|
|
|
|
ARG VERSION_TAG
|
|
|
|
|
|
|
|
# Set Environment Variables
|
|
|
|
ENV DOCKER_ENABLE_SECURITY=false \
|
|
|
|
VERSION_TAG=$VERSION_TAG \
|
2025-01-26 14:10:16 +01:00
|
|
|
JAVA_TOOL_OPTIONS="-XX:+UnlockExperimentalVMOptions \
|
|
|
|
-XX:MaxRAMPercentage=75 \
|
|
|
|
-XX:InitiatingHeapOccupancyPercent=20 \
|
|
|
|
-XX:+G1PeriodicGCInvokesConcurrent \
|
|
|
|
-XX:G1PeriodicGCInterval=10000 \
|
|
|
|
-XX:+UseStringDeduplication \
|
|
|
|
-XX:G1PeriodicGCSystemLoadThreshold=70" \
|
2024-06-01 13:38:10 +02:00
|
|
|
HOME=/home/stirlingpdfuser \
|
|
|
|
PUID=1000 \
|
|
|
|
PGID=1000 \
|
|
|
|
UMASK=022 \
|
|
|
|
FAT_DOCKER=true \
|
2025-02-18 12:57:56 +01:00
|
|
|
INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false \
|
|
|
|
PYTHONPATH=/usr/lib/libreoffice/program:/opt/venv/lib/python3.12/site-packages \
|
|
|
|
UNO_PATH=/usr/lib/libreoffice/program \
|
|
|
|
URE_BOOTSTRAP=file:///usr/lib/libreoffice/program/fundamentalrc
|
2024-08-20 17:17:54 +02:00
|
|
|
|
2024-06-01 13:38:10 +02:00
|
|
|
|
|
|
|
# JDK for app
|
2025-02-18 12:57:56 +01:00
|
|
|
RUN echo "@main https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \
|
|
|
|
echo "@community https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \
|
2024-06-01 13:38:10 +02:00
|
|
|
echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories && \
|
|
|
|
apk upgrade --no-cache -a && \
|
|
|
|
apk add --no-cache \
|
|
|
|
ca-certificates \
|
|
|
|
tzdata \
|
|
|
|
tini \
|
|
|
|
bash \
|
|
|
|
curl \
|
|
|
|
shadow \
|
|
|
|
su-exec \
|
|
|
|
openssl \
|
|
|
|
openssl-dev \
|
2024-06-01 13:57:11 +02:00
|
|
|
openjdk21-jre \
|
2024-06-01 13:38:10 +02:00
|
|
|
# Doc conversion
|
2025-02-07 14:06:19 +01:00
|
|
|
gcompat \
|
|
|
|
libc6-compat \
|
2024-06-01 13:38:10 +02:00
|
|
|
libreoffice \
|
|
|
|
# pdftohtml
|
|
|
|
poppler-utils \
|
|
|
|
# OCR MY PDF (unpaper for descew and other advanced featues)
|
2024-11-26 21:50:35 +01:00
|
|
|
qpdf \
|
2024-06-01 13:38:10 +02:00
|
|
|
tesseract-ocr-data-eng \
|
2025-02-18 12:57:56 +01:00
|
|
|
|
2024-06-01 13:38:10 +02:00
|
|
|
font-terminus font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra \
|
|
|
|
# CV
|
2025-02-07 14:06:19 +01:00
|
|
|
py3-opencv \
|
2025-02-18 12:57:56 +01:00
|
|
|
python3 \
|
|
|
|
py3-pip \
|
|
|
|
py3-pillow@testing \
|
|
|
|
py3-pdf2image@testing && \
|
|
|
|
python3 -m venv /opt/venv && \
|
|
|
|
export PATH="/opt/venv/bin:$PATH" && \
|
|
|
|
pip install --upgrade pip && \
|
|
|
|
pip install --no-cache-dir --upgrade unoserver weasyprint && \
|
|
|
|
ln -s /usr/lib/libreoffice/program/uno.py /opt/venv/lib/python3.12/site-packages/ && \
|
|
|
|
ln -s /usr/lib/libreoffice/program/unohelper.py /opt/venv/lib/python3.12/site-packages/ && \
|
|
|
|
ln -s /usr/lib/libreoffice/program /opt/venv/lib/python3.12/site-packages/LibreOffice && \
|
2024-06-01 13:38:10 +02:00
|
|
|
mv /usr/share/tessdata /usr/share/tessdata-original && \
|
|
|
|
mkdir -p $HOME /configs /logs /customFiles /pipeline/watchedFolders /pipeline/finishedFolders && \
|
|
|
|
fc-cache -f -v && \
|
|
|
|
chmod +x /scripts/* && \
|
|
|
|
chmod +x /scripts/init.sh && \
|
|
|
|
# User permissions
|
|
|
|
addgroup -S stirlingpdfgroup && adduser -S stirlingpdfuser -G stirlingpdfgroup && \
|
|
|
|
chown -R stirlingpdfuser:stirlingpdfgroup $HOME /scripts /usr/share/fonts/opentype/noto /configs /customFiles /pipeline && \
|
2024-12-22 13:00:52 +01:00
|
|
|
chown stirlingpdfuser:stirlingpdfgroup /app.jar
|
2024-06-01 13:38:10 +02:00
|
|
|
|
|
|
|
EXPOSE 8080/tcp
|
|
|
|
# Set user and run command
|
|
|
|
ENTRYPOINT ["tini", "--", "/scripts/init.sh"]
|
2025-02-18 12:57:56 +01:00
|
|
|
CMD ["sh", "-c", "java -Dfile.encoding=UTF-8 -jar /app.jar & /opt/venv/bin/unoserver --port 2003 --interface 0.0.0.0"]
|