From 73f2bfd890469556faf16fdb34aacac185003623 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 24 Jan 2026 15:51:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=20ARM64=20=E4=B8=8A?= =?UTF-8?q?=20endesive=20=E7=B7=A8=E8=AD=AF=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 python3-dev, gcc, libffi-dev 編譯依賴 - 編譯完成後自動移除以減小體積 --- Dockerfile.lite | 266 ++++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 131 deletions(-) diff --git a/Dockerfile.lite b/Dockerfile.lite index 01ca40a..feca456 100644 --- a/Dockerfile.lite +++ b/Dockerfile.lite @@ -45,29 +45,29 @@ WORKDIR /app # 配置 APT 重試機制(解決 Multi-Arch Build 時的網路不穩定問題) RUN echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::http::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::https::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::ftp::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'DPkg::Lock::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries + && echo 'Acquire::http::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'Acquire::https::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'Acquire::ftp::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'DPkg::Lock::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries # install bun RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - unzip \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* + curl \ + unzip \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* # if architecture is arm64, use the arm64 version of bun RUN ARCH=$(uname -m) && \ - if [ "$ARCH" = "aarch64" ]; then \ - curl -fsSL -o bun-linux-aarch64.zip https://github.com/oven-sh/bun/releases/download/bun-v1.3.6/bun-linux-aarch64.zip; \ - else \ - curl -fsSL -o bun-linux-x64-baseline.zip https://github.com/oven-sh/bun/releases/download/bun-v1.3.6/bun-linux-x64-baseline.zip; \ - fi + if [ "$ARCH" = "aarch64" ]; then \ + curl -fsSL -o bun-linux-aarch64.zip https://github.com/oven-sh/bun/releases/download/bun-v1.3.6/bun-linux-aarch64.zip; \ + else \ + curl -fsSL -o bun-linux-x64-baseline.zip https://github.com/oven-sh/bun/releases/download/bun-v1.3.6/bun-linux-x64-baseline.zip; \ + fi RUN unzip -j bun-linux-*.zip -d /usr/local/bin && \ - rm bun-linux-*.zip && \ - chmod +x /usr/local/bin/bun + rm bun-linux-*.zip && \ + chmod +x /usr/local/bin/bun # install dependencies into temp directory # this will cache them and speed up future builds @@ -121,113 +121,113 @@ FROM base AS release # 配置 APT 重試機制 RUN echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::http::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::https::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'Acquire::ftp::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf.d/80-retries \ - && echo 'DPkg::Lock::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries + && echo 'Acquire::http::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'Acquire::https::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'Acquire::ftp::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf.d/80-retries \ + && echo 'DPkg::Lock::Timeout "120";' >> /etc/apt/apt.conf.d/80-retries # 階段 1:基礎系統工具 RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 1/7:安裝基礎系統工具" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - locales \ - ca-certificates \ - curl \ - openssl \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 1/7 完成:基礎系統工具已安裝" + echo "========================================" && \ + echo "📦 階段 1/7:安裝基礎系統工具" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + locales \ + ca-certificates \ + curl \ + openssl \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 1/7 完成:基礎系統工具已安裝" # 階段 2:核心轉換工具 RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 2/6:安裝核心轉換工具" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - ghostscript \ - graphicsmagick \ - poppler-utils \ - potrace \ - qpdf \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 2/6 完成:核心轉換工具已安裝" + echo "========================================" && \ + echo "📦 階段 2/6:安裝核心轉換工具" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + ghostscript \ + graphicsmagick \ + poppler-utils \ + potrace \ + qpdf \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 2/6 完成:核心轉換工具已安裝" # 階段 2.1:安裝 dasel(從 GitHub 下載二進位檔案) RUN echo "" && \ - echo " 🔧 階段 2.1:安裝 dasel..." && \ - ARCH=$(uname -m) && \ - if [ "$ARCH" = "aarch64" ]; then \ - DASEL_ARCH="linux_arm64"; \ - else \ - DASEL_ARCH="linux_amd64"; \ - fi && \ - curl -sSLf "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_${DASEL_ARCH}" -o /usr/local/bin/dasel && \ - chmod +x /usr/local/bin/dasel && \ - echo " ✅ dasel 安裝完成" + echo " 🔧 階段 2.1:安裝 dasel..." && \ + ARCH=$(uname -m) && \ + if [ "$ARCH" = "aarch64" ]; then \ + DASEL_ARCH="linux_arm64"; \ + else \ + DASEL_ARCH="linux_amd64"; \ + fi && \ + curl -sSLf "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_${DASEL_ARCH}" -o /usr/local/bin/dasel && \ + chmod +x /usr/local/bin/dasel && \ + echo " ✅ dasel 安裝完成" # 階段 2.2:安裝 resvg(從 GitHub 下載二進位檔案) RUN echo "" && \ - echo " 🔧 階段 2.2:安裝 resvg..." && \ - ARCH=$(uname -m) && \ - if [ "$ARCH" = "aarch64" ]; then \ - echo " ⚠️ resvg 沒有 ARM64 預編譯版本,跳過安裝"; \ - else \ - curl -sSLf "https://github.com/linebender/resvg/releases/download/v0.44.0/resvg-linux-x86_64.tar.gz" -o /tmp/resvg.tar.gz && \ - tar -xzf /tmp/resvg.tar.gz -C /tmp/ && \ - mv /tmp/resvg /usr/local/bin/resvg && \ - chmod +x /usr/local/bin/resvg && \ - rm -rf /tmp/resvg.tar.gz && \ - echo " ✅ resvg 安裝完成"; \ - fi + echo " 🔧 階段 2.2:安裝 resvg..." && \ + ARCH=$(uname -m) && \ + if [ "$ARCH" = "aarch64" ]; then \ + echo " ⚠️ resvg 沒有 ARM64 預編譯版本,跳過安裝"; \ + else \ + curl -sSLf "https://github.com/linebender/resvg/releases/download/v0.44.0/resvg-linux-x86_64.tar.gz" -o /tmp/resvg.tar.gz && \ + tar -xzf /tmp/resvg.tar.gz -C /tmp/ && \ + mv /tmp/resvg /usr/local/bin/resvg && \ + chmod +x /usr/local/bin/resvg && \ + rm -rf /tmp/resvg.tar.gz && \ + echo " ✅ resvg 安裝完成"; \ + fi # 階段 3:影音處理工具(FFmpeg 精簡版) RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 3/7:安裝影音處理工具(精簡版)" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - ffmpeg \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 3/7 完成:FFmpeg 已安裝" + echo "========================================" && \ + echo "📦 階段 3/7:安裝影音處理工具(精簡版)" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + ffmpeg \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 3/7 完成:FFmpeg 已安裝" # 階段 4:Headless 支援(LibreOffice 需要) # 注意:Lite 版移除 Inkscape 和 VIPS 以減少體積 # GraphicsMagick 已在階段 2 安裝 RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 4/6:安裝 Headless 支援" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - xauth \ - xvfb \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 4/6 完成:Headless 支援已安裝" + echo "========================================" && \ + echo "📦 階段 4/6:安裝 Headless 支援" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + xauth \ + xvfb \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 4/6 完成:Headless 支援已安裝" # 階段 5:文件處理工具(Pandoc) RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 5/6:安裝文件處理工具" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - libemail-outlook-message-perl \ - pandoc \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 5/6 完成:Pandoc 已安裝" + echo "========================================" && \ + echo "📦 階段 5/6:安裝文件處理工具" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + libemail-outlook-message-perl \ + pandoc \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 5/6 完成:Pandoc 已安裝" # 階段 6:LibreOffice(核心文件轉檔引擎 + 基本字型) # 使用完整 libreoffice 以確保所有轉檔功能正常 RUN echo "" && \ - echo "========================================" && \ - echo "📦 階段 6/6:安裝 LibreOffice + 字型" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - libreoffice \ - fonts-noto-cjk \ - fonts-liberation \ - && rm -rf /var/lib/apt/lists/* && \ - echo "✅ 階段 6/6 完成:LibreOffice + 字型已安裝" + echo "========================================" && \ + echo "📦 階段 6/6:安裝 LibreOffice + 字型" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + libreoffice \ + fonts-noto-cjk \ + fonts-liberation \ + && rm -rf /var/lib/apt/lists/* && \ + echo "✅ 階段 6/6 完成:LibreOffice + 字型已安裝" # ============================================================================== # ✅ APT 套件安裝完成 @@ -245,37 +245,41 @@ ENV PDF_SIGN_LOCATION="Taiwan" ENV PDF_SIGN_CONTACT="convertx-cn@localhost" RUN echo "" && \ - echo "========================================" && \ - echo "🔐 安裝 Python + 產生簽章憑證" && \ - echo "========================================" && \ - apt-get update --fix-missing && apt-get install -y --no-install-recommends \ - python3 \ - python3-pip \ - && rm -rf /var/lib/apt/lists/* && \ - pip3 install --no-cache-dir --break-system-packages endesive && \ - mkdir -p /app/certs && \ - openssl req -x509 -newkey rsa:2048 \ - -keyout /tmp/key.pem -out /tmp/cert.pem \ - -days 3650 -nodes \ - -subj "/CN=PDF Packager Default/O=ConvertX-CN Lite/C=TW" && \ - openssl pkcs12 -export \ - -inkey /tmp/key.pem -in /tmp/cert.pem \ - -out /app/certs/default.p12 \ - -passout pass: && \ - rm -f /tmp/key.pem /tmp/cert.pem && \ - chmod 644 /app/certs/default.p12 && \ - echo "✅ Python + PDF 簽章已安裝" + echo "========================================" && \ + echo "🔐 安裝 Python + 產生簽章憑證" && \ + echo "========================================" && \ + apt-get update --fix-missing && apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + python3-dev \ + gcc \ + libffi-dev \ + && rm -rf /var/lib/apt/lists/* && \ + pip3 install --no-cache-dir --break-system-packages endesive && \ + mkdir -p /app/certs && \ + openssl req -x509 -newkey rsa:2048 \ + -keyout /tmp/key.pem -out /tmp/cert.pem \ + -days 3650 -nodes \ + -subj "/CN=PDF Packager Default/O=ConvertX-CN Lite/C=TW" && \ + openssl pkcs12 -export \ + -inkey /tmp/key.pem -in /tmp/cert.pem \ + -out /app/certs/default.p12 \ + -passout pass: && \ + rm -f /tmp/key.pem /tmp/cert.pem && \ + chmod 644 /app/certs/default.p12 && \ + apt-get purge -y --auto-remove gcc python3-dev libffi-dev && \ + echo "✅ Python + PDF 簽章已安裝" # ============================================================================== # 最終清理 + Locale 設定 + 自訂字型(合併以減少 layer) # ============================================================================== RUN rm -rf /usr/share/doc/* \ - && rm -rf /usr/share/man/* \ - && rm -rf /usr/share/info/* \ - && sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ - && sed -i 's/# zh_TW.UTF-8 UTF-8/zh_TW.UTF-8 UTF-8/' /etc/locale.gen \ - && sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen \ - && locale-gen + && rm -rf /usr/share/man/* \ + && rm -rf /usr/share/info/* \ + && sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && sed -i 's/# zh_TW.UTF-8 UTF-8/zh_TW.UTF-8 UTF-8/' /etc/locale.gen \ + && sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen \ + && locale-gen # 安裝自訂字型(標楷體等台灣常用字型) RUN mkdir -p /usr/share/fonts/truetype/custom @@ -286,16 +290,16 @@ RUN fc-cache -fv # Install VTracer binary(向量追蹤工具) # ============================================================================== RUN ARCH=$(uname -m) && \ - if [ "$ARCH" = "aarch64" ]; then \ - VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \ - else \ - VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \ - fi && \ - curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \ - tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \ - mv /tmp/vtracer /usr/local/bin/vtracer && \ - chmod +x /usr/local/bin/vtracer && \ - rm /tmp/vtracer.tar.gz + if [ "$ARCH" = "aarch64" ]; then \ + VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \ + else \ + VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \ + fi && \ + curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \ + tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \ + mv /tmp/vtracer /usr/local/bin/vtracer && \ + chmod +x /usr/local/bin/vtracer && \ + rm /tmp/vtracer.tar.gz COPY --from=install /temp/prod/node_modules node_modules COPY --from=prerelease /app/public/ /app/public/