diff --git a/document-docker/Dockerfile b/document-docker/Dockerfile index 51a76d1..4464030 100644 --- a/document-docker/Dockerfile +++ b/document-docker/Dockerfile @@ -1,33 +1,41 @@ -FROM lscr.io/linuxserver/libreoffice:latest +# 基础镜像:Eclipse Temurin JRE 8(多架构支持,Ubuntu Noble) +FROM eclipse-temurin:8-jre-noble -RUN echo "https://mirrors.tencent.com/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/main/" > /etc/apk/repositories -RUN echo "https://mirrors.tencent.com/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/community/" >> /etc/apk/repositories +# 设置环境变量 +ENV TZ=Asia/Shanghai +ENV LANG=zh_CN.UTF-8 +ENV LANGUAGE=zh_CN.UTF-8 +ENV LC_ALL=zh_CN.UTF-8 -RUN apk update -RUN apk add --no-cache openjdk17-jre -RUN rm -rf /var/cache/apk/* +# 安装 LibreOffice + 字体支持 +RUN rm -f /etc/apt/sources.list.d/* && \ + echo "deb https://mirrors.ustc.edu.cn/ubuntu/ noble main restricted universe multiverse" > /etc/apt/sources.list && \ + echo "deb https://mirrors.ustc.edu.cn/ubuntu/ noble-security main restricted universe multiverse" >> /etc/apt/sources.list && \ + apt update && \ + apt install -y --no-install-recommends \ + libreoffice \ + libreoffice-java-common \ + fonts-dejavu \ + fonts-noto-cjk \ + fontconfig \ + locales \ + tzdata \ + ca-certificates && \ + locale-gen zh_CN.UTF-8 && \ + rm -rf /var/lib/apt/lists/* +# 设置工作目录 WORKDIR /app RUN mkdir -p /app/logs +# 拷贝应用文件、配置、字体 COPY app/document-server-*.jar /app/application.jar COPY app/application.yml /app/application.yml - COPY fonts /usr/share/fonts/truetype - COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh -#设置环境变量默认值,参考 https://hub.docker.com/r/linuxserver/libreoffice -ENV PUID=1000 -ENV PGID=1000 -ENV TZ=Asia/Shanghai -ENV LC_ALL=zh_CN.UTF-8 -ENV TITLE="Libre Office" -ENV DISABLE_IPV6=true -ENV CUSTOM_PORT=3000 -ENV CUSTOM_HTTPS_PORT=3001 - +# 环境变量配置 ENV DOCUMENT_SERVER_PORT=9004 ENV PORT_NUMBERS=2002 ENV MAX_TASKS_PER_PROCESS=200 @@ -36,6 +44,8 @@ ENV GRAMER_SUFFIX="}" ENV GRAMER_CUSTOMIZE_LIST="%" ENV GRAMER_CUSTOMIZE_LIST_STRING_DELIMITING="," +# 暴露端口 EXPOSE 9004 -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +# 启动入口 +ENTRYPOINT ["/entrypoint.sh"] diff --git a/document-docker/entrypoint.sh b/document-docker/entrypoint.sh index 7975ec0..4ccfc07 100644 --- a/document-docker/entrypoint.sh +++ b/document-docker/entrypoint.sh @@ -1,10 +1,19 @@ #!/bin/sh +set -e -# 确保目录存在 -mkdir -p /etc/services.d/java +# ----------------------------- +# 可选:启动 LibreOffice headless 监听服务(端口2002)用于文档转换 +# ----------------------------- +# 你可以根据需要开启或关闭 +libreoffice --headless --accept="socket,host=0.0.0.0,port=${PORT_NUMBERS};urp;" --nologo --nofirststartwizard & +echo "LibreOffice headless started on port ${PORT_NUMBERS}" -# 创建Java服务启动脚本 -cat > /etc/services.d/java/run < /app/start.sh <