fix: 修复Docker构建和路径解析问题

- 在Dockerfile中使用npm中国镜像加速依赖安装
- 修正后端健康检查端点路径
- 修复Docker环境中图片路径解析问题
- 修正前端API地址默认值
This commit is contained in:
congsh
2026-02-27 22:42:53 +08:00
parent 9a301cc434
commit ecf3999d2a
7 changed files with 19 additions and 7 deletions

View File

@@ -12,8 +12,9 @@ WORKDIR /app
COPY package*.json ./
COPY prisma ./prisma/
# Install dependencies
RUN npm ci
# Install dependencies with Chinese mirror
RUN npm config set registry https://registry.npmmirror.com && \
npm ci
# ========================================
# Stage 2: Builder

View File

@@ -69,7 +69,15 @@ export function resolveImagePath(imagePath: string): string {
// 处理 /uploads/ 开头的相对路径
if (imagePath.startsWith('/uploads/')) {
return path.join(getUploadsDir(), imagePath.replace('/uploads/', ''));
const resolved = path.join(getUploadsDir(), imagePath.replace('/uploads/', ''));
// 在 Docker 环境中,确保使用绝对路径
if (process.env.NODE_ENV === 'production' || fs.existsSync('/app/uploads')) {
// Docker 环境:直接使用 /app/uploads/
return `/app/uploads/${imagePath.replace('/uploads/', '')}`;
}
return resolved;
}
// 其他相对路径,使用项目根目录

View File

@@ -39,7 +39,7 @@ services:
- rapidocr
- paddleocr
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:13057/api/health"]
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:13057/health"]
interval: 30s
timeout: 10s
retries: 3

View File

@@ -8,8 +8,9 @@ WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Install dependencies with Chinese mirror
RUN npm config set registry https://registry.npmmirror.com && \
npm ci
# ========================================
# Stage 2: Builder

View File

@@ -6,7 +6,7 @@ import { Settings, Save, CheckCircle, XCircle, Eye, EyeOff, Server, Globe, Datab
// 从环境变量或 localStorage 获取 API 地址
const getDefaultApiUrl = () => {
return import.meta.env.VITE_API_URL || localStorage.getItem('api_base_url') || '/';
return import.meta.env.VITE_API_URL || localStorage.getItem('api_base_url') || '';
};
type ApiConfig = {

BIN
test_ocr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

2
当前问题 Normal file
View File

@@ -0,0 +1,2 @@
识别后无法转为待办
paddleOCR和ripadOCR