File size: 1,049 Bytes
82f76a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM openjdk:17-jdk-slim AS builder

WORKDIR /app

# 安装必要的构建工具
RUN apt-get update && apt-get install -y \
    git \
    curl \
    gradle \
    maven

# 克隆项目代码
RUN git clone https://github.com/Stirling-Tools/Stirling-PDF.git .

# 构建项目
RUN ./gradlew build

FROM openjdk:17-jdk-slim

WORKDIR /app

COPY --from=builder /app/build/libs/*.jar /app/stirling-pdf.jar

RUN mkdir -p /app/logs /app/configs /app/customFiles && \
    chmod -R 777 /app/logs /app/configs /app/customFiles

# 安装运行时依赖
RUN apt-get update && apt-get install -y \
    libreoffice \
    poppler-utils \
    tesseract-ocr \
    tesseract-ocr-eng \
    python3 \
    python3-pip && \
    pip3 install --no-cache-dir unoconv WeasyPrint pdf2image pillow && \
    rm -rf /var/lib/apt/lists/*

# 设置环境变量
ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75"

# 暴露端口 7860
EXPOSE 7860

# 启动应用程序
CMD ["java", "-Dserver.port=7860", "-Dserver.address=0.0.0.0", "-Dfile.encoding=UTF-8", "-jar", "/app/stirling-pdf.jar"]