mistpe commited on
Commit
f81460e
·
verified ·
1 Parent(s): cd286da

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -0
Dockerfile ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM openjdk:17-jdk-slim AS builder
2
+
3
+ WORKDIR /app
4
+
5
+ # 安装必要的构建工具
6
+ RUN apt-get update && apt-get install -y \
7
+ git \
8
+ curl \
9
+ gradle \
10
+ maven
11
+
12
+ # 克隆项目代码
13
+ RUN git clone https://github.com/Stirling-Tools/Stirling-PDF.git .
14
+
15
+ # 构建项目
16
+ RUN ./gradlew build
17
+
18
+ FROM openjdk:17-jdk-slim
19
+
20
+ WORKDIR /app
21
+
22
+ COPY --from=builder /app/build/libs/*.jar /app/stirling-pdf.jar
23
+
24
+ RUN mkdir -p /app/logs /app/configs /app/customFiles && \
25
+ chmod -R 777 /app/logs /app/configs /app/customFiles
26
+
27
+ # 安装运行时依赖
28
+ RUN apt-get update && apt-get install -y \
29
+ libreoffice \
30
+ poppler-utils \
31
+ tesseract-ocr \
32
+ tesseract-ocr-eng \
33
+ python3 \
34
+ python3-pip && \
35
+ pip3 install --no-cache-dir unoconv WeasyPrint pdf2image pillow && \
36
+ rm -rf /var/lib/apt/lists/*
37
+
38
+ # 设置环境变量
39
+ ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75"
40
+
41
+ # 暴露端口 7860
42
+ EXPOSE 7860
43
+
44
+ # 启动应用程序
45
+ CMD ["java", "-Dserver.port=7860", "-Dserver.address=0.0.0.0", "-Dfile.encoding=UTF-8", "-jar", "/app/stirling-pdf.jar"]