File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed
Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change 1+ # 构建阶段
2+ FROM openjdk:17-jdk-slim AS builder
3+
4+ # 安装Maven
5+ RUN apt-get update && apt-get install -y \
6+ curl \
7+ && rm -rf /var/lib/apt/lists/*
8+
9+ # 下载并安装Maven(使用更稳定的源)
10+ RUN cd /tmp && \
11+ curl -O https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz && \
12+ tar -xzf apache-maven-3.9.9-bin.tar.gz && \
13+ mv apache-maven-3.9.9 /opt/maven
14+
15+ ENV MAVEN_HOME=/opt/maven
16+ ENV PATH=$MAVEN_HOME/bin:$PATH
17+
18+ # 创建工作目录
19+ WORKDIR /official
20+
21+ # 复制Maven配置和源代码
22+ COPY pom.xml .
23+ COPY src ./src
24+
25+ # 构建项目
26+ RUN mvn clean package -DskipTests
27+
28+ # 运行阶段
129FROM openjdk:17-jdk-slim
230
331# 安装必要的工具和字体库
@@ -6,9 +34,8 @@ RUN apt-get update && apt-get install -y \
634 fontconfig \
735 libfreetype6 \
836 fonts-noto-cjk \
9- curl \
10- jq \
1137 && locale-gen zh_CN.UTF-8 \
38+ && update-locale LANG=zh_CN.UTF-8 \
1239 && rm -rf /var/lib/apt/lists/*
1340
1441# 设置中文环境变量
@@ -19,9 +46,14 @@ ENV LANG=zh_CN.UTF-8 \
1946# 创建目录
2047WORKDIR /official
2148
22- # 复制应用JAR包
23- COPY target/Official-*.jar official.jar
49+ # 从构建阶段复制JAR文件
50+ COPY --from=builder /official/ target/Official-*.jar official.jar
2451
52+ # 暴露端口
2553EXPOSE 8080
2654
55+ # 添加JVM参数以支持UTF-8编码和字体处理
56+ ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.awt.headless=true"
57+
58+ # 启动应用
2759ENTRYPOINT ["java" , "-jar" , "official.jar" , "--spring.profiles.active=prod" ]
You can’t perform that action at this time.
0 commit comments