fix: update port in dockerfile

This commit is contained in:
liuyuanchuang
2026-02-05 22:20:01 +08:00
parent 36172ba4ff
commit c372a4afbe
3 changed files with 150 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ ENV PYTHONUNBUFFERED=1 \
# Application config (override defaults for container)
# Use 127.0.0.1 for --network host mode, or override with -e for bridge mode
PP_DOCLAYOUT_MODEL_DIR=/root/.cache/modelscope/hub/models/PaddlePaddle/PP-DocLayoutV2 \
PADDLEOCR_VL_URL=http://127.0.0.1:8000/v1
PADDLEOCR_VL_URL=http://127.0.0.1:8001/v1
# Set working directory
WORKDIR /app

148
PORT_CONFIGURATION.md Normal file
View File

@@ -0,0 +1,148 @@
# 端口配置检查总结
## 搜索命令
```bash
# 搜索所有 8000 端口引用
rg "(127\.0\.0\.1|localhost):8000"
# 或使用 grep
grep -r -n -E "(127\.0\.0\.1|localhost):8000" . \
--exclude-dir=.git \
--exclude-dir=__pycache__ \
--exclude-dir=.venv \
--exclude="*.pyc"
```
## 当前端口配置 ✅
### PaddleOCR-VL 服务 (端口 8001)
**代码文件** - 全部正确 ✅:
- `app/core/config.py:25``http://127.0.0.1:8001/v1`
- `app/services/ocr_service.py:492``http://localhost:8001/v1`
- `app/core/dependencies.py:53``http://localhost:8001/v1` (fallback)
- `Dockerfile:18``http://127.0.0.1:8001/v1`
### Mineru API 服务 (端口 8000)
**代码文件** - 全部正确 ✅:
- `app/core/config.py:28``http://127.0.0.1:8000/file_parse`
- `app/services/ocr_service.py:489``http://127.0.0.1:8000/file_parse`
- `app/core/dependencies.py:52``http://127.0.0.1:8000/file_parse` (fallback)
### 文档和示例文件
以下文件包含示例命令,使用 `localhost:8000`,这些是文档用途,不影响实际运行:
- `docs/*.md` - 各种 curl 示例
- `README.md` - 配置示例 (使用 8080)
- `docker-compose.yml` - 使用 8080
- `openspec/changes/add-doc-processing-api/design.md` - 设计文档
## 验证服务端口
### 1. 检查 vLLM (PaddleOCR-VL)
```bash
# 应该在 8001
lsof -i:8001
# 验证模型
curl http://127.0.0.1:8001/v1/models
```
### 2. 检查 Mineru API
```bash
# 应该在 8000
lsof -i:8000
# 验证健康状态
curl http://127.0.0.1:8000/health
```
### 3. 检查你的 FastAPI 应用
```bash
# 应该在 8053
lsof -i:8053
# 验证健康状态
curl http://127.0.0.1:8053/health
```
## 修复历史
### 已修复的问题 ✅
1. **app/services/ocr_service.py:492**
- 从: `paddleocr_vl_url: str = "http://localhost:8000/v1"`
- 到: `paddleocr_vl_url: str = "http://localhost:8001/v1"`
2. **Dockerfile:18**
- 从: `PADDLEOCR_VL_URL=http://127.0.0.1:8000/v1`
- 到: `PADDLEOCR_VL_URL=http://127.0.0.1:8001/v1`
3. **app/core/config.py:25**
- 已经是正确的 8001
## 环境变量配置
如果需要自定义端口,可以设置环境变量:
```bash
# PaddleOCR-VL (默认 8001)
export PADDLEOCR_VL_URL=http://127.0.0.1:8001/v1
# Mineru API (默认 8000)
export MINER_OCR_API_URL=http://127.0.0.1:8000/file_parse
```
或在 `.env` 文件中:
```env
PADDLEOCR_VL_URL=http://127.0.0.1:8001/v1
MINER_OCR_API_URL=http://127.0.0.1:8000/file_parse
```
## Docker 部署注意事项
在 Docker 容器中,使用:
- `--network host`: 使用 `127.0.0.1`
- `--network bridge`: 使用 `host.docker.internal` 或容器名
示例:
```bash
docker run \
--network host \
-e PADDLEOCR_VL_URL=http://127.0.0.1:8001/v1 \
-e MINER_OCR_API_URL=http://127.0.0.1:8000/file_parse \
doc-processer
```
## 快速验证脚本
```bash
#!/bin/bash
echo "检查端口配置..."
# 检查代码中的配置
echo -e "\n=== PaddleOCR-VL URLs (应该是 8001) ==="
rg "paddleocr_vl.*8\d{3}" app/
echo -e "\n=== Mineru API URLs (应该是 8000) ==="
rg "miner.*8\d{3}" app/
# 检查服务状态
echo -e "\n=== 检查运行中的服务 ==="
echo "Port 8000 (Mineru):"
lsof -i:8000 | grep LISTEN || echo " 未运行"
echo "Port 8001 (PaddleOCR-VL):"
lsof -i:8001 | grep LISTEN || echo " 未运行"
echo "Port 8053 (FastAPI):"
lsof -i:8053 | grep LISTEN || echo " 未运行"
```
保存为 `check_ports.sh`,然后运行:
```bash
chmod +x check_ports.sh
./check_ports.sh
```

View File

@@ -489,7 +489,7 @@ class MineruOCRService(OCRServiceBase):
api_url: str = "http://127.0.0.1:8000/file_parse",
image_processor: Optional[ImageProcessor] = None,
converter: Optional[Converter] = None,
paddleocr_vl_url: str = "http://localhost:8000/v1",
paddleocr_vl_url: str = "http://localhost:8001/v1",
):
"""Initialize Local API service.