From 52978ec9ad313f9b183eb40dca663ef10c1761dd Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com.> Date: Sat, 1 Jun 2024 12:38:10 +0100 Subject: [PATCH 1/2] fat docker --- Dockerfile | 2 +- Dockerfile-fat | 84 +++++++++++++++++++ Dockerfile-ultra-lite | 2 +- scripts/init-without-ocr.sh | 8 +- .../resources/templates/fragments/navbar.html | 6 +- test.sh | 3 +- 6 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 Dockerfile-fat diff --git a/Dockerfile b/Dockerfile index 6aab1d8b..de813f6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et su-exec \ openssl \ openssl-dev \ - openjdk21-jre \ + openjdk21-jre-headless \ # Doc conversion libreoffice \ # pdftohtml diff --git a/Dockerfile-fat b/Dockerfile-fat new file mode 100644 index 00000000..f902c9f2 --- /dev/null +++ b/Dockerfile-fat @@ -0,0 +1,84 @@ +# Build the application +FROM gradle:7.6-jdk17 AS build + +# 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 \ +./gradlew clean build + +# Main stage +FROM alpine:3.20.0 + +# 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 \ + JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -XX:MaxRAMPercentage=75" \ + HOME=/home/stirlingpdfuser \ + PUID=1000 \ + PGID=1000 \ + UMASK=022 \ + FAT_DOCKER=true \ + INSTALL_BOOK_AND_ADVANCED_HTML_OPS=true + + +# JDK for app +RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ + 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 \ + calibre@testing \ + shadow \ + su-exec \ + openssl \ + openssl-dev \ + openjdk21-jre-headless \ +# Doc conversion + libreoffice \ +# pdftohtml + poppler-utils \ +# OCR MY PDF (unpaper for descew and other advanced featues) + ocrmypdf \ + tesseract-ocr-data-eng \ + font-terminus font-dejavu font-noto font-noto-cjk font-awesome font-noto-extra \ +# CV + py3-opencv \ +# python3/pip + python3 && \ + wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ +# uno unoconv and HTML + pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ + 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 && \ + chown stirlingpdfuser:stirlingpdfgroup /app.jar && \ + tesseract --list-langs + +EXPOSE 8080/tcp + +# Set user and run command +ENTRYPOINT ["tini", "--", "/scripts/init.sh"] +CMD ["java", "-Dfile.encoding=UTF-8", "-jar", "/app.jar"] diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index e3718497..62a00a6e 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -31,7 +31,7 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et curl \ shadow \ su-exec \ - openjdk21-jre && \ + openjdk21-jre-headless && \ # User permissions mkdir /configs /logs /customFiles && \ chmod +x /scripts/*.sh && \ diff --git a/scripts/init-without-ocr.sh b/scripts/init-without-ocr.sh index 761dd08d..99054031 100644 --- a/scripts/init-without-ocr.sh +++ b/scripts/init-without-ocr.sh @@ -11,14 +11,16 @@ if [ ! -z "$PGID" ] && [ "$PGID" != "$(getent group stirlingpdfgroup | cut -d: - fi umask "$UMASK" || true -if [[ "$INSTALL_BOOK_AND_ADVANCED_HTML_OPS" == "true" ]]; then +if [[ "$INSTALL_BOOK_AND_ADVANCED_HTML_OPS" == "true" && "$FAT_DOCKER" != "true" ]]; then apk add --no-cache calibre@testing fi -/scripts/download-security-jar.sh +if [[ "$FAT_DOCKER" != "true" ]]; then + /scripts/download-security-jar.sh +fi if [[ -n "$LANGS" ]]; then - /scripts/installFonts.sh $LANGS + /scripts/installFonts.sh $LANGS fi echo "Setting permissions and ownership for necessary directories..." diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index c296ab7d..c349d396 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -233,7 +233,7 @@ -