mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Conflicts: # .gitignore # app/core/build.gradle # app/core/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java # app/core/src/main/java/stirling/software/SPDF/service/WeeklyActiveUsersService.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkController.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkProperties.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkService.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkSyncStateRepository.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/MeteredInputSignatureRepository.java # app/proprietary/src/main/java/stirling/software/proprietary/accountlink/UsageCounterRepository.java # app/proprietary/src/main/java/stirling/software/proprietary/cluster/valkey/ValkeyJobStore.java # app/proprietary/src/main/java/stirling/software/proprietary/failure/FileRunEventRepository.java # app/proprietary/src/main/java/stirling/software/proprietary/security/CustomLogoutSuccessHandler.java # app/proprietary/src/main/java/stirling/software/proprietary/security/configuration/SecurityConfiguration.java # app/proprietary/src/main/java/stirling/software/proprietary/security/oauth2/CustomOAuth2AuthenticationFailureHandler.java # app/proprietary/src/main/java/stirling/software/proprietary/security/saml2/CustomSaml2ResponseAuthenticationConverter.java # app/proprietary/src/main/java/stirling/software/proprietary/service/ua/FontEmbeddingService.java # app/proprietary/src/main/java/stirling/software/proprietary/web/AuditWebFilter.java # app/proprietary/src/main/java/stirling/software/proprietary/workflow/controller/WorkflowParticipantController.java # app/proprietary/src/main/java/stirling/software/proprietary/workflow/service/WorkflowSessionService.java # app/saas/src/main/java/stirling/software/saas/accountlink/AccountLinkController.java # app/saas/src/main/java/stirling/software/saas/ai/controller/AiCreateController.java # app/saas/src/main/java/stirling/software/saas/ai/controller/AiCreateInternalController.java # app/saas/src/main/java/stirling/software/saas/legal/LegalDocumentRegistry.java # app/saas/src/main/java/stirling/software/saas/payg/entitlement/EntitlementGuard.java # app/saas/src/main/java/stirling/software/saas/procurement/legal/AgreementAssembler.java # app/saas/src/main/java/stirling/software/saas/procurement/service/ProcurementService.java # app/saas/src/main/java/stirling/software/saas/security/SupabaseSecurityConfig.java # build.gradle # docker/embedded/Dockerfile # docker/embedded/Dockerfile.fat # engine/src/stirling/models/tool_models.py
155 lines
7.5 KiB
Docker
155 lines
7.5 KiB
Docker
# Stirling-PDF - Full version (embedded frontend)
|
|
# Uses pre-built base image for fast builds
|
|
|
|
ARG BASE_VERSION=1.0.2@sha256:c7698687f486707ddef9e0298587ca8b44c4e96185e1bdb0c3d119eb2bf9a82e
|
|
ARG BASE_IMAGE=stirlingtools/stirling-pdf-base:${BASE_VERSION}
|
|
|
|
# Stage 1: Build the Java application and frontend
|
|
FROM gradle:9.7.1-jdk25@sha256:d868117760a7c92214705f47ed173116a5d13e58d68702f974ff30acd062737e AS app-build
|
|
|
|
ARG TASK_VERSION=3.52.0
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl ca-certificates \
|
|
&& update-ca-certificates \
|
|
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
|
&& apt-get install -y --no-install-recommends nodejs \
|
|
&& ARCH=$(dpkg --print-architecture) \
|
|
&& curl -fsSL "https://github.com/go-task/task/releases/download/v${TASK_VERSION}/task_${TASK_VERSION}_linux_${ARCH}.deb" -o /tmp/task.deb \
|
|
&& dpkg -i /tmp/task.deb \
|
|
&& rm /tmp/task.deb \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# JDK 25+: --add-exports is no longer accepted via JAVA_TOOL_OPTIONS; use JDK_JAVA_OPTIONS instead
|
|
ENV JDK_JAVA_OPTIONS="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
|
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
|
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
|
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
|
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
|
|
|
|
WORKDIR /app
|
|
|
|
COPY build.gradle settings.gradle gradlew ./
|
|
COPY gradle/ gradle/
|
|
COPY buildSrc/build.gradle buildSrc/
|
|
COPY buildSrc/src/main/ buildSrc/src/main/
|
|
COPY app/core/build.gradle app/core/
|
|
COPY app/common/build.gradle app/common/
|
|
COPY app/proprietary/build.gradle app/proprietary/
|
|
|
|
# Use system gradle instead of gradlew to avoid SSL issues downloading gradle distribution on emulated arm64
|
|
RUN gradle dependencies --no-daemon || true
|
|
|
|
COPY . .
|
|
|
|
ARG PROTOTYPES_BUILD=false
|
|
ARG STIRLING_FLAVOR=proprietary
|
|
ENV STIRLING_FLAVOR=${STIRLING_FLAVOR}
|
|
# Embed the admin portal app at /portal. Set true by the deploy workflow when the
|
|
# portal or AI layers change; defaults false so normal builds skip the extra app.
|
|
ARG BUILD_PORTAL=false
|
|
|
|
# Which Stirling account the portal connects to. Build-time because Vite inlines VITE_* into the
|
|
# bundle; there is no runtime override. Empty leaves the committed .env.proprietary defaults, which
|
|
# is what an ordinary image wants: no Stirling account and no connect flow. The publishable key is
|
|
# client-side by design, not a secret. Pass the URL and the key from the same Supabase project or
|
|
# the browser accepts the pair and Supabase rejects it, which surfaces later as "session expired".
|
|
ARG VITE_SUPABASE_URL=""
|
|
ARG VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=""
|
|
ARG VITE_SAAS_API_URL=""
|
|
|
|
# Bundle only the JPDFium native for this image's target arch.
|
|
ARG TARGETARCH
|
|
# Exported only when non-empty: Vite reads process.env ahead of the .env files, so exporting an
|
|
# empty value would blank the committed default rather than fall back to it.
|
|
RUN JPDFIUM_PLATFORM="$([ "$TARGETARCH" = arm64 ] && echo linux-arm64 || echo linux-x64)" && \
|
|
if [ -n "${VITE_SUPABASE_URL}" ]; then export VITE_SUPABASE_URL="${VITE_SUPABASE_URL}"; fi; \
|
|
if [ -n "${VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY}" ]; then export VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY="${VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY}"; fi; \
|
|
if [ -n "${VITE_SAAS_API_URL}" ]; then export VITE_SAAS_API_URL="${VITE_SAAS_API_URL}"; fi; \
|
|
STIRLING_FLAVOR=${STIRLING_FLAVOR} \
|
|
gradle clean build \
|
|
-PbuildWithFrontend=true \
|
|
-PbuildWithPortal=${BUILD_PORTAL} \
|
|
-PjpdfiumPlatforms="$JPDFIUM_PLATFORM" \
|
|
-PprototypesMode=${PROTOTYPES_BUILD} \
|
|
-x spotlessApply -x spotlessCheck -x test -x sonarqube \
|
|
--no-daemon
|
|
|
|
# Stage 2: Final runtime image on top of pre-built base
|
|
FROM ${BASE_IMAGE}
|
|
|
|
ARG VERSION_TAG
|
|
|
|
WORKDIR /app
|
|
|
|
# Quarkus uber runner-jar (self-contained, all dependencies inside). init-without-ocr.sh launches
|
|
# it with `java -jar /app/app.jar`. Replaces the former Spring Boot layered-jar extraction
|
|
# (java -Djarmode=tools extract --layers + spring-boot-loader layers), which the Quarkus uber-jar
|
|
# does not support.
|
|
COPY --link --from=app-build --chown=1000:1000 \
|
|
/app/app/core/build/stirling-pdf-*-runner.jar /app/app.jar
|
|
|
|
COPY --link --from=app-build --chown=1000:1000 \
|
|
/app/build/libs/restart-helper.jar /restart-helper.jar
|
|
COPY --link --chown=1000:1000 scripts/ /scripts/
|
|
|
|
# Fonts go to system dir, root ownership is correct (world-readable)
|
|
COPY app/core/src/main/resources/static/fonts/*.ttf /usr/share/fonts/truetype/
|
|
|
|
# Permissions and configuration
|
|
RUN set -eux; \
|
|
chmod +x /scripts/*; \
|
|
ln -s /logs /app/logs; \
|
|
ln -s /configs /app/configs; \
|
|
ln -s /customFiles /app/customFiles; \
|
|
ln -s /pipeline /app/pipeline; \
|
|
ln -s /storage /app/storage; \
|
|
chown -h stirlingpdfuser:stirlingpdfgroup /app/logs /app/configs /app/customFiles /app/pipeline /app/storage; \
|
|
chown stirlingpdfuser:stirlingpdfgroup /app; \
|
|
chmod 750 /tmp/stirling-pdf; \
|
|
chmod 750 /tmp/stirling-pdf/heap_dumps; \
|
|
fc-cache -f
|
|
|
|
# Write version to a file so it is readable by scripts without env-var inheritance.
|
|
# init-without-ocr.sh reads /etc/stirling_version for the AOT cache fingerprint.
|
|
RUN echo "${VERSION_TAG:-dev}" > /etc/stirling_version
|
|
|
|
# Environment variables
|
|
ENV VERSION_TAG=$VERSION_TAG \
|
|
STIRLING_AOT_ENABLE="false" \
|
|
STIRLING_JVM_PROFILE="balanced" \
|
|
_JVM_OPTS_BALANCED="-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/configs/heap_dumps -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:G1HeapRegionSize=4m -XX:G1PeriodicGCInterval=60000 -XX:+UseStringDeduplication -XX:+UseCompactObjectHeaders -XX:+ExplicitGCInvokesConcurrent -Dspring.threads.virtual.enabled=true -Djava.awt.headless=true" \
|
|
_JVM_OPTS_PERFORMANCE="-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/configs/heap_dumps -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:+UseCompactObjectHeaders -XX:+UseStringDeduplication -XX:+AlwaysPreTouch -XX:+ExplicitGCInvokesConcurrent -Dspring.threads.virtual.enabled=true -Djava.awt.headless=true" \
|
|
JAVA_CUSTOM_OPTS="" \
|
|
HOME=/home/stirlingpdfuser \
|
|
PUID=1000 \
|
|
PGID=1000 \
|
|
UMASK=022 \
|
|
STIRLING_TEMPFILES_DIRECTORY=/tmp/stirling-pdf \
|
|
TMPDIR=/tmp/stirling-pdf \
|
|
TEMP=/tmp/stirling-pdf \
|
|
TMP=/tmp/stirling-pdf \
|
|
DBUS_SESSION_BUS_ADDRESS=/dev/null \
|
|
SAL_TMP=/tmp/stirling-pdf/libre
|
|
|
|
# Metadata labels
|
|
LABEL org.opencontainers.image.title="Stirling-PDF" \
|
|
org.opencontainers.image.description="Full version with Calibre, LibreOffice, Tesseract, OCRmyPDF" \
|
|
org.opencontainers.image.source="https://github.com/Stirling-Tools/Stirling-PDF" \
|
|
org.opencontainers.image.licenses="MIT" \
|
|
org.opencontainers.image.vendor="Stirling-Tools" \
|
|
org.opencontainers.image.url="https://www.stirlingpdf.com" \
|
|
org.opencontainers.image.documentation="https://docs.stirlingpdf.com" \
|
|
maintainer="Stirling-Tools" \
|
|
org.opencontainers.image.authors="Stirling-Tools" \
|
|
org.opencontainers.image.version="${VERSION_TAG}" \
|
|
org.opencontainers.image.keywords="PDF, manipulation, API, Spring Boot, React"
|
|
|
|
EXPOSE 8080/tcp
|
|
STOPSIGNAL SIGTERM
|
|
|
|
HEALTHCHECK --interval=30s --timeout=15s --start-period=120s --retries=5 \
|
|
CMD curl -fs --max-time 10 http://localhost:8080${SYSTEM_ROOTURIPATH:-''}/api/v1/info/status || exit 1
|
|
|
|
ENTRYPOINT ["tini", "--", "/scripts/init.sh"]
|
|
CMD []
|