diff --git a/Dockerfile b/Dockerfile index 4afb7ce..d9671e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/README.md b/README.md index 7822aa0..f6564bf 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,93 @@ ![ConvertX](images/logo.png) -# ConvertX +# ConvertX-CN(完整版) -[![Docker](https://github.com/C4illin/ConvertX/actions/workflows/docker-publish.yml/badge.svg?branch=main)](https://github.com/C4illin/ConvertX/actions/workflows/docker-publish.yml) -[![ghcr.io Pulls](https://img.shields.io/badge/dynamic/json?logo=github&url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FC4illin%2FConvertX%2Fconvertx.json&query=%24.downloads&label=ghcr.io%20pulls&cacheSeconds=14400)](https://github.com/C4illin/ConvertX/pkgs/container/ConvertX) -[![Docker Pulls](https://img.shields.io/docker/pulls/c4illin/convertx?style=flat&logo=docker&label=dockerhub%20pulls&link=https%3A%2F%2Fhub.docker.com%2Frepository%2Fdocker%2Fc4illin%2Fconvertx%2Fgeneral)](https://hub.docker.com/r/c4illin/convertx) -[![GitHub Release](https://img.shields.io/github/v/release/C4illin/ConvertX)](https://github.com/C4illin/ConvertX/pkgs/container/convertx) -![GitHub commits since latest release](https://img.shields.io/github/commits-since/C4illin/ConvertX/latest) -![GitHub repo size](https://img.shields.io/github/repo-size/C4illin/ConvertX) -![Docker container size](https://ghcr-badge.egpl.dev/c4illin/convertx/size?color=%230375b6&tag=latest&label=image+size&trim=) +[![Docker](https://github.com/pi-docket/ConvertX-CN/actions/workflows/release.yml/badge.svg)](https://github.com/pi-docket/ConvertX-CN/actions/workflows/release.yml) +[![Docker Pulls](https://img.shields.io/docker/pulls/convertx/convertx-cn?style=flat&logo=docker&label=Docker%20Hub)](https://hub.docker.com/r/convertx/convertx-cn) +[![GitHub Release](https://img.shields.io/github/v/release/pi-docket/ConvertX-CN)](https://github.com/pi-docket/ConvertX-CN/releases) -C4illin%2FConvertX | Trendshift +> 🎉 **這是完整版 ConvertX-CN image,已內建所有轉換依賴!** +> +> 使用者 **不需要自己寫 Dockerfile**,直接 `docker run` 或 `docker compose up` 即可使用。 - +基於 [C4illin/ConvertX](https://github.com/C4illin/ConvertX) 的中文優化版本。 -A self-hosted online file converter. Supports over a thousand different formats. Written with TypeScript, Bun and Elysia. +--- -## Features +## ✨ 完整版特色 -- Convert files to different formats -- Process multiple files at once -- Password protection -- Multiple accounts +此 image 已經內建以下所有依賴,開箱即用: -## Converters supported +| 類別 | 內建內容 | +|------|----------| +| **文件轉換** | LibreOffice (headless)、Pandoc | +| **LaTeX** | TexLive Full(完整版,支援所有 LaTeX 需求) | +| **OCR 識別** | Tesseract OCR + 繁體中文、簡體中文、日文、韓文、英文、德文語言包 | +| **CJK 字型** | Noto CJK(中日韓)、Noto Emoji、微軟核心字型、標楷體 | +| **影音轉換** | FFmpeg、ImageMagick、GraphicsMagick | +| **向量圖形** | Inkscape、Potrace、VTracer、resvg | +| **電子書** | Calibre | +| **其他** | Ghostscript、MuPDF、Poppler、libheif、libjxl 等 | + +--- + +## 🚀 快速開始 + +### 方法一:Docker Run + +```bash +docker run -d \ + --name convertx-cn \ + -p 3000:3000 \ + -v ./data:/app/data \ + -e TZ=Asia/Taipei \ + convertx/convertx-cn:latest +``` + +### 方法二:Docker Compose(推薦) + +建立 `docker-compose.yml`: + +```yaml +services: + convertx: + image: convertx/convertx-cn:latest + container_name: convertx-cn + restart: unless-stopped + ports: + - "3000:3000" + volumes: + - ./data:/app/data + environment: + - TZ=Asia/Taipei + - JWT_SECRET=請更換為一個長且隨機的字串 + - ACCOUNT_REGISTRATION=false + - HTTP_ALLOWED=false + - AUTO_DELETE_EVERY_N_HOURS=24 +``` + +啟動服務: + +```bash +docker compose up -d +``` + +然後瀏覽 `http://localhost:3000` 並建立第一個帳號。 + +--- + +## 📦 Docker Image + +| Image | 說明 | +|-------|------| +| `convertx/convertx-cn:latest` | 最新穩定版 | +| `convertx/convertx-cn:v0.1.1` | 指定版本 | + +> ⚠️ 由於內建完整依賴,image 大小約 4-6 GB,首次下載需要較長時間。 + +--- + +## 🔧 支援的轉換器 | Converter | Use case | Converts from | Converts to | | --------------------------------------------------------------- | ---------------- | ------------- | ----------- | @@ -50,116 +114,67 @@ A self-hosted online file converter. Supports over a thousand different formats. -Any missing converter? Open an issue or pull request! +缺少什麼轉換器?歡迎開 issue 或 pull request! -## Deployment +--- -> [!WARNING] -> If you can't login, make sure you are accessing the service over localhost or https otherwise set HTTP_ALLOWED=true +## ⚙️ 環境變數 -```yml -# docker-compose.yml -services: - convertx: - image: ghcr.io/c4illin/convertx - container_name: convertx - restart: unless-stopped - ports: - - "3000:3000" - environment: - - JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() if unset - # - HTTP_ALLOWED=true # uncomment this if accessing it over a non-https connection - volumes: - - ./data:/app/data -``` +所有環境變數皆為選填,建議設定 `JWT_SECRET`。 -or +| 變數名稱 | 預設值 | 說明 | +|----------|--------|------| +| JWT_SECRET | randomUUID() | 用於簽署 JWT 的密鑰字串 | +| ACCOUNT_REGISTRATION | false | 是否允許註冊新帳號 | +| HTTP_ALLOWED | false | 是否允許 HTTP 連線(僅本地使用) | +| ALLOW_UNAUTHENTICATED | false | 是否允許未登入使用 | +| AUTO_DELETE_EVERY_N_HOURS | 24 | 自動刪除超過 N 小時的檔案(0 = 停用) | +| WEBROOT | | 子路徑部署,例如 `/convertx` | +| FFMPEG_ARGS | | FFmpeg 輸入參數,例如 `-hwaccel vaapi` | +| FFMPEG_OUTPUT_ARGS | | FFmpeg 輸出參數,例如 `-preset veryfast` | +| HIDE_HISTORY | false | 隱藏歷史紀錄頁面 | +| LANGUAGE | en | 日期格式語言(BCP 47 格式) | +| TZ | UTC | 時區設定 | +| MAX_CONVERT_PROCESS | 0 | 最大同時轉換數(0 = 無限制) | -```bash -docker run -p 3000:3000 -v ./data:/app/data ghcr.io/c4illin/convertx -``` +--- -Then visit `http://localhost:3000` in your browser and create your account. Don't leave it unconfigured and open, as anyone can register the first account. - -If you get unable to open database file run `chown -R $USER:$USER path` on the path you choose. - -### Environment variables - -All are optional, JWT_SECRET is recommended to be set. - -| Name | Default | Description | -| ---------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| JWT_SECRET | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token | -| ACCOUNT_REGISTRATION | false | Allow users to register accounts | -| HTTP_ALLOWED | false | Allow HTTP connections, only set this to true locally | -| ALLOW_UNAUTHENTICATED | false | Allow unauthenticated users to use the service, only set this to true locally | -| AUTO_DELETE_EVERY_N_HOURS | 24 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable | -| WEBROOT | | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" | -| FFMPEG_ARGS | | Arguments to pass to the input file of ffmpeg, e.g. `-hwaccel vaapi`. See https://github.com/C4illin/ConvertX/issues/190 for more info about hw-acceleration. | -| FFMPEG_OUTPUT_ARGS | | Arguments to pass to the output of ffmpeg, e.g. `-preset veryfast` | -| HIDE_HISTORY | false | Hide the history page | -| LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) | -| UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users | -| MAX_CONVERT_PROCESS | 0 | Maximum number of concurrent conversion processes allowed. Set to 0 for unlimited. | - -### Docker images - -There is a `:latest` tag that is updated with every release and a `:main` tag that is updated with every push to the main branch. `:latest` is recommended for normal use. - -The image is available on [GitHub Container Registry](https://github.com/C4illin/ConvertX/pkgs/container/ConvertX) and [Docker Hub](https://hub.docker.com/r/c4illin/convertx). - -| Image | What it is | -| -------------------------------------- | -------------------------------- | -| `image: ghcr.io/c4illin/convertx` | The latest release on ghcr | -| `image: ghcr.io/c4illin/convertx:main` | The latest commit on ghcr | -| `image: c4illin/convertx` | The latest release on docker hub | -| `image: c4illin/convertx:main` | The latest commit on docker hub | - -![Release image size](https://ghcr-badge.egpl.dev/c4illin/convertx/size?color=%230375b6&tag=latest&label=release+image&trim=) -![Dev image size](https://ghcr-badge.egpl.dev/c4illin/convertx/size?color=%230375b6&tag=main&label=dev+image&trim=) - - - -### Tutorial +## 📖 教學文章 > [!NOTE] -> These are written by other people, and may be outdated, incorrect or wrong. +> 以下教學由社群撰寫,可能有過時或錯誤之處。 -Tutorial in french: +- 法文教學: +- 中文教學: +- 波蘭文教學: -Tutorial in chinese: +--- -Tutorial in polish: - -## Screenshots +## 📸 Screenshots ![ConvertX Preview](images/preview.png) -## Development +## 🛠️ 開發 -0. Install [Bun](https://bun.sh/) and Git -1. Clone the repository +0. 安裝 [Bun](https://bun.sh/) 和 Git +1. Clone 這個 repository 2. `bun install` 3. `bun run dev` -Pull requests are welcome! See open issues for the list of todos. The ones tagged with "converter request" are quite easy. Help with docs and cleaning up in issues are also very welcome! +歡迎 Pull Request!請使用 [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) 格式。 -Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) for commit messages. +--- -## Contributors +## 🙏 致謝 + +本專案基於 [C4illin/ConvertX](https://github.com/C4illin/ConvertX) 開發。 Image with all contributors -![Alt](https://repobeats.axiom.co/api/embed/dcdabd0564fcdcccbf5680c1bdc2efad54a3d4d9.svg "Repobeats analytics image") +--- -## Star History +## 📜 License - - - - - Star History Chart - - +MIT License diff --git a/compose.yaml b/compose.yaml index 2af5058..e7d079f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,22 +1,44 @@ -# This compose file is for development and testing purposes only. See README for production deployment instructions. +# ============================================================================== +# ConvertX-CN 部署範例(docker-compose.yml / compose.yaml) +# +# 🎉 這是完整版 image,已內建所有轉換依賴: +# - LibreOffice (headless) +# - TexLive Full +# - Tesseract OCR + 中日韓英德語言包 +# - CJK 字型(Noto CJK、微軟核心字型、標楷體) +# - Pandoc、FFmpeg、ImageMagick 等所有轉換器 +# +# ✅ 使用者不需要自己寫 Dockerfile +# ✅ 直接 docker compose up -d 即可使用 +# ============================================================================== services: convertx: - build: - context: . - # dockerfile: Debian.Dockerfile + image: convertx/convertx-cn:latest + container_name: convertx-cn + restart: unless-stopped + ports: + - "3000:3000" volumes: - ./data:/app/data - environment: # Defaults are listed below. All are optional. - - ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account) - - JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default - - HTTP_ALLOWED=false # setting this to true is unsafe, only set this to true locally - - ALLOW_UNAUTHENTICATED=false # allows anyone to use the service without logging in, only set this to true locally - - AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable - # - FFMPEG_ARGS=-hwaccel vulkan # additional arguments to pass to ffmpeg - # - WEBROOT=/convertx # the root path of the web interface, leave empty to disable - # - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false - - TZ=Europe/Stockholm # set your timezone, defaults to UTC - # - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices - ports: - - 3000:3000 + environment: + # === 帳號設定 === + - ACCOUNT_REGISTRATION=false # 是否允許註冊新帳號(首次帳號不受此限制) + - JWT_SECRET=請更換為一個長且隨機的字串 # 若不設定則使用 randomUUID() + + # === 安全設定 === + - HTTP_ALLOWED=false # 是否允許非 HTTPS 連線(僅本地測試時設為 true) + - ALLOW_UNAUTHENTICATED=false # 是否允許未登入使用(僅本地測試時設為 true) + + # === 檔案管理 === + - AUTO_DELETE_EVERY_N_HOURS=24 # 自動刪除超過 N 小時的檔案(0 = 停用) + + # === 時區設定 === + - TZ=Asia/Taipei + + # === 可選設定 === + # - WEBROOT=/convertx # 子路徑部署(例如 example.com/convertx/) + # - HIDE_HISTORY=true # 隱藏歷史紀錄頁面 + # - LANGUAGE=zh-TW # 日期格式語言 + # - FFMPEG_ARGS=-hwaccel vaapi # FFmpeg 硬體加速參數 + # - MAX_CONVERT_PROCESS=4 # 最大同時轉換數(0 = 無限制) diff --git a/fonts/BiauKai.ttf b/fonts/BiauKai.ttf new file mode 100644 index 0000000..f8d9ea9 Binary files /dev/null and b/fonts/BiauKai.ttf differ