feat: bundle full conversion dependencies into image

This commit is contained in:
Your Name 2026-01-19 22:00:45 +08:00
parent 7632584eb6
commit a9b65248b8
4 changed files with 232 additions and 138 deletions

View file

@ -1,5 +1,12 @@
# ==============================================================================
# ConvertX-CN 完整版 Dockerfile
# 內建所有轉換依賴LibreOffice / TexLive Full / OCR / CJK 字型
# 支援 linux/amd64, linux/arm64 multi-arch build
# ==============================================================================
FROM debian:trixie-slim AS base
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
LABEL org.opencontainers.image.source="https://github.com/pi-docket/ConvertX-CN"
LABEL org.opencontainers.image.description="ConvertX-CN - 完整版檔案轉換服務,內建所有依賴"
WORKDIR /app
# install bun
@ -43,8 +50,12 @@ RUN bun run build
# copy production dependencies and source code into final image
FROM base AS release
# install additional dependencies
RUN apt-get update && apt-get install -y \
# ==============================================================================
# 完整依賴安裝(單一 RUN 層,優化 cache
# 包含:轉換工具 + TexLive Full + LibreOffice + OCR + CJK 字型
# ==============================================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
# === 基礎轉換工具 ===
assimp-utils \
calibre \
dasel \
@ -55,37 +66,76 @@ RUN apt-get update && apt-get install -y \
graphicsmagick \
imagemagick-7.q16 \
inkscape \
latexmk \
libheif-examples \
libjxl-tools \
libreoffice \
libva2 \
libvips-tools \
libemail-outlook-message-perl \
lmodern \
mupdf-tools \
pandoc \
poppler-utils \
potrace \
python3-numpy \
python3-tinycss2 \
resvg \
texlive \
texlive-fonts-recommended \
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex \
# === LibreOffice (headless) ===
libreoffice \
# === TexLive 完整版(支援所有 LaTeX 需求)===
texlive-full \
latexmk \
lmodern \
# === Pandoc 文件轉換 ===
pandoc \
# === OCR 支援Tesseract + 多語言包)===
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-chi-tra \
tesseract-ocr-chi-sim \
tesseract-ocr-jpn \
tesseract-ocr-kor \
tesseract-ocr-deu \
# === CJK 字型(中日韓完整支援)===
fonts-noto-cjk \
fonts-noto-core \
fonts-noto-extra \
fonts-noto-color-emoji \
# === 微軟核心字型 ===
ttf-mscorefonts-installer \
# === Python 依賴 ===
python3 \
python3-pip \
python3-numpy \
python3-tinycss2 \
pipx \
--no-install-recommends \
# === 系統工具 ===
ca-certificates \
locales \
&& pipx install "markitdown[all]" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add pipx bin directory to PATH
ENV PATH="/root/.local/bin:${PATH}"
# Install VTracer binary
# ==============================================================================
# 設定 locale避免中文 PDF 亂碼)
# ==============================================================================
RUN 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 && \
sed -i 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i 's/# ko_KR.UTF-8 UTF-8/ko_KR.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LANG=zh_TW.UTF-8
ENV LC_ALL=zh_TW.UTF-8
# ==============================================================================
# 安裝自訂字型(標楷體等台灣常用字型)
# ==============================================================================
RUN mkdir -p /usr/share/fonts/truetype/custom
COPY fonts/ /usr/share/fonts/truetype/custom/
RUN fc-cache -fv
# ==============================================================================
# Install VTracer binary向量追蹤工具
# ==============================================================================
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \
@ -102,11 +152,18 @@ COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /app/public/ /app/public/
COPY --from=prerelease /app/dist /app/dist
# COPY . .
RUN mkdir data
EXPOSE 3000/tcp
# used for calibre
# ==============================================================================
# 環境變數
# ==============================================================================
# Calibre 需要
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
# Pandoc PDF 引擎
ENV PANDOC_PDF_ENGINE=xelatex
# Node 環境
ENV NODE_ENV=production
ENTRYPOINT [ "bun", "run", "dist/src/index.js" ]