# 构建阶段 - 创建包含LibreOffice的基础镜像
FROM openjdk:8-jre-slim as base-builder

ENV LANG=zh_CN.UTF-8 \
    LANGUAGE=zh_CN:zh \
    LC_ALL=zh_CN.UTF-8 \
    DEBIAN_FRONTEND=noninteractive

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 && \
    apt-get install -y --no-install-recommends \
        fonts-liberation \
        fonts-dejavu-core \
        fonts-wqy-microhei \
        fonts-noto-cjk \
        fontconfig \
        locales \
        libreoffice-core \
        libreoffice-writer \
        libreoffice-l10n-zh-cn && \
    echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen && \
    locale-gen zh_CN.UTF-8 && \
    fc-cache -f -v && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN mkdir -p /home/app
WORKDIR /home/app

# 最终阶段
FROM base-builder

# 只拷贝jar包
COPY target/yd-oss-api-1.0-SNAPSHOT-exec.jar /home/app/yd-oss-api.jar

# 执行命令启动jar，并设置JVM内存参数
ENTRYPOINT ["java", "-Xmx256m", "-Xms128m", "-jar", "/home/app/yd-oss-api.jar"]
EXPOSE 9106