Commit 6d17dd5c by zhangxingmin

push

parent ff5778e4
# 基础镜像 - 使用更轻量的slim版本
# 使用更小的基础镜像
FROM openjdk:8-jre-slim
# 维护人
LABEL maintainer="zxm<2060197959@qq.com>"
# 创建目录
RUN mkdir -p /home/app
# 使用阿里云镜像源加速下载
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
# 精简安装必要的组件(只保留核心功能)
RUN apt-get update && \
WORKDIR /home/app
# 设置环境变量(提前设置以利用缓存)
ENV LANG=zh_CN.UTF-8 \
LANGUAGE=zh_CN:zh \
LC_ALL=zh_CN.UTF-8 \
DEBIAN_FRONTEND=noninteractive
# 使用阿里云镜像源并安装必要组件(合并所有操作到一个RUN层)
RUN set -eux; \
# 备份原源文件
cp /etc/apt/sources.list /etc/apt/sources.list.bak; \
# 使用阿里云镜像源
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
# 更新并安装最小化包
apt-get update; \
apt-get install -y --no-install-recommends \
libreoffice-core \
libreoffice-writer \
libreoffice-l10n-zh-cn \
fonts-liberation \
fonts-dejavu-core \
fonts-wqy-microhei \
fonts-wqy-zenhei \
fonts-noto-cjk \
fontconfig \
locales && \
# 设置中文 locale
echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen && \
locale-gen zh_CN.UTF-8 && \
locales; \
# 设置中文locale
echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen zh_CN.UTF-8; \
# 清理缓存和临时文件
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
apt-get clean; \
rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/var/cache/apt/* \
/usr/share/doc/* \
/usr/share/man/*; \
# 更新字体缓存
fc-cache -f -v
# 设置环境变量
ENV LANG=zh_CN.UTF-8
ENV LANGUAGE=zh_CN:zh
ENV LC_ALL=zh_CN.UTF-8
# 验证安装(只保留必要的验证)
RUN echo "=== 验证字体安装 ===" && \
fc-list :lang=zh | head -5 && \
echo "=== 验证LibreOffice ===" && \
libreoffice --version | head -1
# 拷贝项目jar(放在较晚的步骤,利用缓存)
fc-cache -f -v; \
# 验证安装
echo "=== 基础验证 ==="; \
java -version; \
libreoffice --version; \
fc-list :lang=zh | head -3
# 拷贝项目jar(放在最后以利用Docker缓存)
COPY target/yd-oss-api-1.0-SNAPSHOT-exec.jar /home/app/yd-oss-api.jar
# 预生成JVM类数据共享文件,加速后续启动
RUN java -Xshare:dump -jar /home/app/yd-oss-api.jar || true
# 使用 exec 形式启动,优化信号处理
ENTRYPOINT ["java", "-jar", "/home/app/yd-oss-api.jar"]
# 暴露端口
EXPOSE 9106
# 执行命令启动jar,使用优化的JVM参数
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:InitialRAMPercentage=50.0", \
"-XX:MaxRAMPercentage=80.0", \
"-XX:+UseG1GC", \
"-XX:+UseStringDeduplication", \
"-XX:+TieredCompilation", \
"-XX:TieredStopAtLevel=1", \
"-Xshare:on", \
"-jar", "/home/app/yd-oss-api.jar"]
EXPOSE 9106
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment