feat: Docker化部署 - 單容器架構轉換

將 Tool_OCR 從 macOS conda 環境轉換為 Docker 單容器部署方案。
前後端整合於同一容器,通過 Nginx 反向代理,僅對外暴露單一端口。

## 新增功能
- Docker 單容器架構(Frontend + Backend + Nginx)
- 多階段構建優化鏡像大小
- Supervisor 進程管理
- 健康檢查機制
- 完整部署文檔

## 技術細節
- 對外端口:12015(原 12010 已被佔用)
- 內部架構:Nginx(12015) → FastAPI(8000)
- 前端靜態文件由 Nginx 直接服務
- API 請求通過 Nginx 反向代理

## 系統依賴完善
- libmagic1:文件類型檢測
- LibreOffice:Office 文檔轉換
- paddlex[ocr]:PP-StructureV3 版面分析
- 中日韓字體支援

## 配置調整
- 環境變數路徑:macOS 路徑 → 容器絕對路徑
- 前端 API URL:修正為統一端口 12015
- Pip 安裝:延長超時至 600 秒,重試 5 次
- CRLF 轉換:自動處理 Windows 換行符

## 清理
- 移除臨時文檔(API_FIX_SUMMARY.md 等 7 個文檔)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-11-13 13:12:59 +08:00
parent 57cf91271c
commit 0f81d5e70b
26 changed files with 1166 additions and 2985 deletions

52
.env
View File

@@ -1,5 +1,5 @@
# Tool_OCR - Environment Configuration Template
# Copy this file to .env and fill in your actual values
# Tool_OCR - Docker Environment Configuration
# Copy this file to .env when deploying with Docker
# ===== Database Configuration =====
MYSQL_HOST=mysql.theaken.com
@@ -9,18 +9,17 @@ MYSQL_PASSWORD=WLeSCi0yhtc7
MYSQL_DATABASE=db_A060
# ===== Application Configuration =====
# Server ports
BACKEND_PORT=12010
FRONTEND_PORT=12011
# External port (exposed to host)
FRONTEND_PORT=12010
# Security
# Security (IMPORTANT: Change SECRET_KEY in production!)
SECRET_KEY=your-secret-key-here-please-change-this-to-random-string
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440
# ===== OCR Configuration =====
# PaddleOCR model directory
PADDLEOCR_MODEL_DIR=./models/paddleocr
# PaddleOCR model directory (inside container)
PADDLEOCR_MODEL_DIR=/app/backend/models/paddleocr
# Supported languages (comma-separated)
OCR_LANGUAGES=ch,en,japan,korean
# Default confidence threshold
@@ -33,24 +32,24 @@ MAX_OCR_WORKERS=4
MAX_UPLOAD_SIZE=52428800
# Allowed file extensions (comma-separated)
ALLOWED_EXTENSIONS=png,jpg,jpeg,pdf,bmp,tiff,doc,docx,ppt,pptx
# Upload directories
UPLOAD_DIR=./uploads
TEMP_DIR=./uploads/temp
PROCESSED_DIR=./uploads/processed
IMAGES_DIR=./uploads/images
# Upload directories (inside container)
UPLOAD_DIR=/app/backend/uploads
TEMP_DIR=/app/backend/uploads/temp
PROCESSED_DIR=/app/backend/uploads/processed
IMAGES_DIR=/app/backend/uploads/images
# ===== Export Configuration =====
# Storage directories
STORAGE_DIR=./storage
MARKDOWN_DIR=./storage/markdown
JSON_DIR=./storage/json
EXPORTS_DIR=./storage/exports
# Storage directories (inside container)
STORAGE_DIR=/app/backend/storage
MARKDOWN_DIR=/app/backend/storage/markdown
JSON_DIR=/app/backend/storage/json
EXPORTS_DIR=/app/backend/storage/exports
# ===== PDF Generation Configuration =====
# Pandoc path (auto-detected if installed via brew)
PANDOC_PATH=/opt/homebrew/bin/pandoc
# WeasyPrint font directory
FONT_DIR=/System/Library/Fonts
# Pandoc path (inside container)
PANDOC_PATH=/usr/bin/pandoc
# Font directory (inside container)
FONT_DIR=/usr/share/fonts
# Default PDF page size
PDF_PAGE_SIZE=A4
# Default PDF margins (mm)
@@ -64,8 +63,8 @@ PDF_MARGIN_RIGHT=20
ENABLE_TRANSLATION=false
# Translation engine: offline (argostranslate) or api (future)
TRANSLATION_ENGINE=offline
# Argostranslate models directory
ARGOSTRANSLATE_MODELS_DIR=./models/argostranslate
# Argostranslate models directory (inside container)
ARGOSTRANSLATE_MODELS_DIR=/app/backend/models/argostranslate
# ===== Background Tasks Configuration =====
# Task queue type: memory (default) or redis (future)
@@ -75,8 +74,9 @@ TASK_QUEUE_TYPE=memory
# ===== CORS Configuration =====
# Allowed origins (comma-separated, * for all)
CORS_ORIGINS=http://localhost:12011,http://127.0.0.1:12011
# For Docker, use the external URL
CORS_ORIGINS=http://localhost:12010,http://127.0.0.1:12010
# ===== Logging Configuration =====
LOG_LEVEL=INFO
LOG_FILE=./logs/app.log
LOG_FILE=/app/backend/logs/app.log