convertor/docs/部署指南/docker-compose.md
Your Name a06df23b1d feat: 新增 OCRmyPDF 轉換引擎 (v0.1.14)
## 新功能
- OCRmyPDF 轉換引擎:將掃描版 PDF 轉換為可搜尋 PDF
  - 支援 7 種語言:en, zh-TW, zh, ja, ko, de, fr
  - 與 PDFMathTranslate 風格一致的 UI 格式 (pdf-<lang>)
  - 自動偵測頁面方向並旋轉
  - 自動校正傾斜
  - 跳過已有文字層的頁面
  - 詳細的 5 階段處理進度輸出

## 建置
- Dockerfile:安裝 ocrmypdf 與 Tesseract OCR 語言包

## 文件
- 更新 OCR 功能文件
- 文件目錄結構改為中文名稱

## 測試
- 修復 BabelDOC 和 PDFMathTranslate 測試的 OCR mock
- 所有 345 個測試通過
2026-01-23 16:28:33 +08:00

163 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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=your-secret-key
```
---
## 映像檔選擇
```yaml
image: convertx/convertx-cn:latest # 最新穩定版
image: convertx/convertx-cn:v0.1.9 # 指定版本
```
- `latest`:自動獲取最新版本,適合測試環境
- 指定版本:適合生產環境,避免意外升級
詳見 [版本選擇指南](../versions/)。
---
## 連接埠設定
```yaml
ports:
- "3000:3000" # 主機埠:容器埠
- "8080:3000" # 使用 8080 埠
- "127.0.0.1:3000:3000" # 僅本地存取
```
| 設定 | 說明 |
| ----------------------- | -------------------- |
| `"3000:3000"` | 所有網路介面可存取 |
| `"127.0.0.1:3000:3000"` | 僅本機可存取 |
| `"8080:3000"` | 使用 8080 埠對外開放 |
---
## 資料儲存
### 使用資料夾掛載(推薦)
```yaml
volumes:
- ./data:/app/data
```
- 資料存在主機上的 `./data` 資料夾
- 方便備份、遷移、直接存取
### 使用 Docker Volume
```yaml
volumes:
- convertx_data:/app/data
volumes:
convertx_data:
```
- 資料由 Docker 管理
- 備份需透過 Docker 指令
---
## 環境變數
### 必要設定
```yaml
environment:
- JWT_SECRET=your-secret-key-at-least-32-chars
```
### 建議設定
```yaml
environment:
- TZ=Asia/Taipei
- HTTP_ALLOWED=true # 本地測試
- ACCOUNT_REGISTRATION=true
```
### 生產環境設定
```yaml
environment:
- TZ=Asia/Taipei
- JWT_SECRET=your-production-secret
- HTTP_ALLOWED=false
- TRUST_PROXY=true
- ACCOUNT_REGISTRATION=false
- AUTO_DELETE_EVERY_N_HOURS=24
```
完整環境變數說明請參考 [環境變數文件](../配置設定/環境變數.md)。
---
## 重啟策略
```yaml
restart: unless-stopped # 推薦
restart: always # 總是重啟
restart: on-failure # 僅失敗時重啟
restart: "no" # 不自動重啟
```
---
## 資源限制
```yaml
deploy:
resources:
limits:
memory: 4G
cpus: "2"
reservations:
memory: 1G
cpus: "0.5"
```
---
## 健康檢查
```yaml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/healthcheck"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
```
---
## 完整範例
請參考 [Docker Compose 範例資料夾](../docker-compose/)
- `compose.minimal.yml` - 最精簡設定
- `compose.production.yml` - 生產環境
- `compose.reference.yml` - 完整參考