fix: 调整构建镜像采用的镜像源

This commit is contained in:
wizardchen
2025-08-14 00:45:19 +08:00
committed by lyingbug
parent 8b43931886
commit 57c6e04e54
6 changed files with 211 additions and 195 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
GIN_MODE=debug GIN_MODE=debug
# Ollama 服务的基准 URL,用于连接本地/其他服务器上运行的 Ollama 服务 # Ollama 服务的基准 URL,用于连接本地/其他服务器上运行的 Ollama 服务
OLLAMA_BASE_URL=http://host.docker.internal:11435 OLLAMA_BASE_URL=http://host.docker.internal:11434
# 存储配置 # 存储配置
# 主数据库类型(postgres/mysql) # 主数据库类型(postgres/mysql)
+3 -6
View File
@@ -37,10 +37,9 @@ FROM alpine:3.17
WORKDIR /app WORKDIR /app
# Install runtime dependencies # Install runtime dependencies
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
RUN apk update --allow-untrusted apk update && apk upgrade && \
RUN apk upgrade --allow-untrusted apk add --no-cache build-base postgresql-client mysql-client ca-certificates tzdata sed curl bash supervisor vim wget
RUN apk add --no-cache build-base postgresql17-client mysql-client ca-certificates tzdata sed curl bash supervisor vim wget curl --allow-untrusted
# Copy the binary from the builder stage # Copy the binary from the builder stage
COPY --from=builder /app/WeKnora . COPY --from=builder /app/WeKnora .
@@ -73,5 +72,3 @@ RUN mkdir -p /data/files && \
# Run supervisor instead of direct application start # Run supervisor instead of direct application start
CMD ["supervisord", "-c", "/etc/supervisor.d/supervisord.conf"] CMD ["supervisord", "-c", "/etc/supervisor.d/supervisord.conf"]
# CMD ["sh", "/app/scripts/start_app.sh"]
# CMD ["sleep", "infinity"]
+28 -40
View File
@@ -1,8 +1,14 @@
ARG PLATFORM=linux/amd64 ARG PLATFORM=linux/amd64
# =========================
# 构建阶段 # 构建阶段
# =========================
FROM --platform=${PLATFORM} python:3.9-slim AS builder FROM --platform=${PLATFORM} python:3.9-slim AS builder
# 切换 apt 源到清华
RUN sed -i 's@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources && \
sed -i 's@http://security.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources
WORKDIR /app WORKDIR /app
# 安装构建依赖 # 安装构建依赖
@@ -31,36 +37,38 @@ RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.19
COPY services/docreader/requirements.txt . COPY services/docreader/requirements.txt .
# 安装依赖 # 安装依赖
RUN pip cache purge && pip install --no-cache-dir -r requirements.txt RUN pip cache purge && pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 预下载 PP-OCRv5 模型 # 预下载 PP-OCRv5 模型
RUN mkdir -p /root/.paddlex/official_models RUN mkdir -p /root/.paddlex/official_models && \
wget https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-OCRv5_server_det_infer.tar \
RUN wget https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-OCRv5_server_det_infer.tar \ -O /root/.paddlex/official_models/PP-OCRv5_server_det_infer.tar && \
-O /root/.paddlex/official_models/PP-OCRv5_server_det_infer.tar && \
wget https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-OCRv5_server_rec_infer.tar \ wget https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-OCRv5_server_rec_infer.tar \
-O /root/.paddlex/official_models/PP-OCRv5_server_rec_infer.tar -O /root/.paddlex/official_models/PP-OCRv5_server_rec_infer.tar && \
tar -xf /root/.paddlex/official_models/PP-OCRv5_server_det_infer.tar -C /root/.paddlex/official_models/ && \
# 解压模型文件 tar -xf /root/.paddlex/official_models/PP-OCRv5_server_rec_infer.tar -C /root/.paddlex/official_models/ && \
RUN tar -xf /root/.paddlex/official_models/PP-OCRv5_server_det_infer.tar -C /root/.paddlex/official_models/ && \ rm -rf /root/.paddlex/official_models/PP-OCRv5_server_det_infer.tar /root/.paddlex/official_models/PP-OCRv5_server_rec_infer.tar
tar -xf /root/.paddlex/official_models/PP-OCRv5_server_rec_infer.tar -C /root/.paddlex/official_models/
# 复制源代码和生成脚本 # 复制源代码和生成脚本
COPY services/docreader/src/ /app/src/ COPY services/docreader/src/ /app/src/
COPY services/docreader/scripts/ /app/scripts/ COPY services/docreader/scripts/ /app/scripts/
# 使用正确的Python模块路径运行ocr.py
# RUN cd /app && PYTHONPATH=/app python -m src.parser.ocr
# 确保模型目录存在 # 确保模型目录存在
RUN ls -la /root/.paddlex/official_models RUN ls -la /root/.paddlex/official_models
# 生成 protobuf 代码 # 生成 protobuf 代码
RUN chmod +x /app/scripts/generate_proto.sh && bash /app/scripts/generate_proto.sh RUN chmod +x /app/scripts/generate_proto.sh && bash /app/scripts/generate_proto.sh
# =========================
# 运行阶段 # 运行阶段
# =========================
FROM --platform=${PLATFORM} python:3.9-slim AS runner FROM --platform=${PLATFORM} python:3.9-slim AS runner
# 切换 apt 源到清华
RUN sed -i 's@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources && \
sed -i 's@http://security.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources
WORKDIR /app WORKDIR /app
# 安装运行时依赖 # 安装运行时依赖
@@ -73,11 +81,6 @@ RUN apt-get update && apt-get install -y \
libglib2.0-0 \ libglib2.0-0 \
antiword \ antiword \
supervisor \ supervisor \
&& rm -rf /var/lib/apt/lists/*
# 安装所需依赖
RUN apt-get update && apt-get install -y \
wget \
vim \ vim \
tar \ tar \
dpkg \ dpkg \
@@ -90,50 +93,35 @@ RUN apt-get update && apt-get install -y \
libsm6 \ libsm6 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 下载并安装最新版本的 LibreOffice 25.2.4 # 下载并安装 LibreOffice(区分架构)
RUN mkdir -p /tmp/libreoffice && \ RUN mkdir -p /tmp/libreoffice && cd /tmp/libreoffice && \
cd /tmp/libreoffice && \
if [ "$(uname -m)" = "x86_64" ]; then \ if [ "$(uname -m)" = "x86_64" ]; then \
wget -q https://mirrors.tuna.tsinghua.edu.cn/libreoffice/libreoffice/stable/25.2.4/deb/x86_64/LibreOffice_25.2.4_Linux_x86-64_deb.tar.gz && \ wget -q https://mirrors.tuna.tsinghua.edu.cn/libreoffice/libreoffice/stable/25.2.4/deb/x86_64/LibreOffice_25.2.4_Linux_x86-64_deb.tar.gz && \
tar -xzf LibreOffice_25.2.4_Linux_x86-64_deb.tar.gz && \ tar -xzf LibreOffice_25.2.4_Linux_x86-64_deb.tar.gz && \
cd LibreOffice_25.2.4*_Linux_x86-64_deb/DEBS && \ cd LibreOffice_25.2.4*_Linux_x86-64_deb/DEBS && dpkg -i *.deb; \
dpkg -i *.deb; \
elif [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then \ elif [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then \
wget -q https://mirrors.aliyun.com/libreoffice/testing/25.8.0/deb/aarch64/LibreOffice_25.8.0.3_Linux_aarch64_deb.tar.gz && \ wget -q https://mirrors.aliyun.com/libreoffice/testing/25.8.0/deb/aarch64/LibreOffice_25.8.0.3_Linux_aarch64_deb.tar.gz && \
tar -xzf LibreOffice_25.8.0.3_Linux_aarch64_deb.tar.gz && \ tar -xzf LibreOffice_25.8.0.3_Linux_aarch64_deb.tar.gz && \
cd LibreOffice_25.8.0*_Linux_aarch64_deb/DEBS && \ cd LibreOffice_25.8.0*_Linux_aarch64_deb/DEBS && dpkg -i *.deb; \
dpkg -i *.deb; \
else \ else \
echo "Unsupported architecture: $(uname -m)" && exit 1; \ echo "Unsupported architecture: $(uname -m)" && exit 1; \
fi && \ fi && \
cd / && \ cd / && rm -rf /tmp/libreoffice
rm -rf /tmp/libreoffice
# 设置 LibreOffice 环境变量 # 设置 LibreOffice 环境变量
RUN if [ "$(uname -m)" = "x86_64" ]; then \ RUN echo 'export LIBREOFFICE_PATH=/opt/libreoffice25.2/program/soffice' >> /etc/environment;
echo 'export LIBREOFFICE_PATH=/opt/libreoffice25.2/program/soffice' >> /etc/environment; \
elif [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then \
echo 'export LIBREOFFICE_PATH=/opt/libreoffice25.2/program/soffice' >> /etc/environment; \
fi
ENV LIBREOFFICE_PATH=/opt/libreoffice25.2/program/soffice
# 从构建阶段复制已安装的依赖和生成的代码 # 从构建阶段复制已安装的依赖和生成的代码
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin COPY --from=builder /usr/local/bin /usr/local/bin
# 复制 PaddleOCR 模型到运行阶段
COPY --from=builder /root/.paddlex/official_models /root/.paddlex/official_models COPY --from=builder /root/.paddlex/official_models /root/.paddlex/official_models
COPY --from=builder /app/src /app/src
# 安装 Playwright 浏览器 # 安装 Playwright 浏览器
RUN python -m playwright install webkit RUN python -m playwright install webkit
#RUN python -m playwright install-deps webkit
COPY --from=builder /app/src /app/src
# 设置 Python 路径 # 设置 Python 路径
ENV PYTHONPATH=/app/src ENV PYTHONPATH=/app/src
RUN cd /app/src && python -m download_deps RUN cd /app/src && python -m download_deps
# 创建supervisor配置 # 创建supervisor配置
+1
View File
@@ -127,6 +127,7 @@ const handleScroll = debounce(checkScrollBottom, 200)
const getMessageList = () => { const getMessageList = () => {
if (loading.value) return; if (loading.value) return;
loading.value = true; loading.value = true;
usemenuStore.clearMenuArr();
getSessionsList(currentPage.value, page_size.value).then(res => { getSessionsList(currentPage.value, page_size.value).then(res => {
if (res.data && res.data.length) { if (res.data && res.data.length) {
res.data.forEach(item => { res.data.forEach(item => {
+3
View File
@@ -20,6 +20,9 @@ export const useMenuStore = defineStore('menuStore', {
} }
), ),
actions: { actions: {
clearMenuArr() {
this.menuArr[1].children = reactive<object[]>([]);
},
updatemenuArr(obj: any) { updatemenuArr(obj: any) {
this.menuArr[1].children?.push(obj); this.menuArr[1].children?.push(obj);
}, },
@@ -557,16 +557,13 @@
<!-- 多模态功能测试区域 --> <!-- 多模态功能测试区域 -->
<div v-if="canTestMultimodal" class="multimodal-test"> <div v-if="canTestMultimodal" class="multimodal-test">
<h5>多模态功能测试</h5> <h5>功能测试</h5>
<div class="test-description"> <p class="test-desc">上传图片测试VLM模型的图片描述和文字识别功能</p>
<p>上传一张测试图片,验证VLM模型的Caption生成和OCR文字识别功能</p>
</div>
<!-- 测试操作区域 --> <div class="test-area">
<div class="multimodal-test-container"> <!-- 上传区域 -->
<!-- 左侧:图片上传和预览区域 --> <div class="upload-section">
<div class="test-image-section"> <div class="upload-buttons">
<div class="test-upload">
<t-upload <t-upload
ref="imageUpload" ref="imageUpload"
v-model="multimodalTest.uploadedFiles" v-model="multimodalTest.uploadedFiles"
@@ -578,58 +575,55 @@
> >
<t-button theme="default" variant="outline" size="small"> <t-button theme="default" variant="outline" size="small">
<t-icon name="upload" /> <t-icon name="upload" />
选择测试图片 选择图片
</t-button> </t-button>
</t-upload> </t-upload>
<t-button
v-if="multimodalTest.selectedFile"
theme="primary"
size="small"
:loading="multimodalTest.testing"
@click="startMultimodalTest"
style="margin-left: 10px;"
>
开始测试
</t-button>
</div>
<!-- 选中的图片预览 -->
<div v-if="multimodalTest.selectedFile" class="image-preview-container">
<div class="image-preview">
<img :src="multimodalTest.previewUrl" alt="测试图片" />
</div>
<div class="image-info">
<span>{{ multimodalTest.selectedFile.name }}</span>
<span>{{ formatFileSize(multimodalTest.selectedFile.size) }}</span>
</div>
</div> </div>
</div> </div>
<!-- 右侧:测试结果显示 --> <!-- 图片预览 -->
<div class="test-result-section" v-if="multimodalTest.result"> <div v-if="multimodalTest.selectedFile" class="image-preview">
<img :src="multimodalTest.previewUrl" alt="测试图片" />
<div class="image-meta">
<span class="file-name">{{ multimodalTest.selectedFile.name }}</span>
<span class="file-size">{{ formatFileSize(multimodalTest.selectedFile.size) }}</span>
</div>
</div>
<div class="test-button-wrapper">
<t-button
v-if="multimodalTest.selectedFile"
theme="primary"
size="small"
:loading="multimodalTest.testing"
@click="startMultimodalTest"
>
开始测试
</t-button>
</div>
<!-- 测试结果 -->
<div v-if="multimodalTest.result" class="test-result">
<div v-if="multimodalTest.result.success" class="result-success"> <div v-if="multimodalTest.result.success" class="result-success">
<h6>测试结果</h6> <h6>测试结果</h6>
<div v-if="multimodalTest.result.caption" class="result-item"> <div v-if="multimodalTest.result.caption" class="result-item">
<label>图片描述 (Caption):</label> <label>图片描述:</label>
<div class="result-content">{{ multimodalTest.result.caption }}</div> <div class="result-text">{{ multimodalTest.result.caption }}</div>
</div> </div>
<div v-if="multimodalTest.result.ocr" class="result-item"> <div v-if="multimodalTest.result.ocr" class="result-item">
<label>文字识别 (OCR):</label> <label>文字识别:</label>
<div class="result-content">{{ multimodalTest.result.ocr }}</div> <div class="result-text">{{ multimodalTest.result.ocr }}</div>
</div> </div>
<div v-if="multimodalTest.result.processing_time" class="result-item time-item"> <div v-if="multimodalTest.result.processing_time" class="result-time">
<label>处理时间:</label> 处理时间: {{ multimodalTest.result.processing_time }}ms
<div class="result-content">{{ multimodalTest.result.processing_time }}ms</div>
</div> </div>
</div> </div>
<div v-else class="result-error"> <div v-else class="result-error">
<h6>测试失败</h6> <h6>测试失败</h6>
<div class="error-content"> <div class="error-msg">
<t-icon name="error-circle" /> <t-icon name="error-circle" />
{{ multimodalTest.result.message || '多模态处理失败' }} {{ multimodalTest.result.message || '多模态处理失败' }}
</div> </div>
@@ -3275,136 +3269,169 @@ const onDimensionInput = (event: any) => {
.multimodal-test { .multimodal-test {
margin-top: 20px; margin-top: 20px;
padding: 15px; padding: 20px;
background: #fcf3ea; background: #f8fff9;
border-radius: 6px; border-radius: 10px;
border-left: 3px solid #ff7000; border: 1px solid #e8f5e8;
h5 { h5 {
font-size: 16px; font-size: 16px;
color: #d46b08; color: #07c05f;
margin-bottom: 10px; margin-bottom: 8px;
font-weight: 600;
} }
.test-description { .test-desc {
margin-bottom: 15px; margin-bottom: 16px;
font-size: 13px; font-size: 13px;
color: #666; color: #6b7280;
line-height: 1.4;
} }
.multimodal-test-container { .test-area {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
gap: 20px; gap: 16px;
}
@media (max-width: 768px) { .upload-section {
flex-direction: column; display: flex;
flex-direction: column;
gap: 12px;
.upload-buttons {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
}
.image-preview {
text-align: center;
padding: 20px;
background: white;
border-radius: 10px;
border: 1px solid #e8f5e8;
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.08);
img {
max-width: 100%;
max-height: 200px;
object-fit: contain;
border-radius: 8px;
margin-bottom: 12px;
border: 1px solid #f0f0f0;
} }
.test-image-section { .image-meta {
flex: 1; display: flex;
min-width: 0; justify-content: space-between;
align-items: center;
.test-upload { padding: 8px 12px;
margin-bottom: 15px; background: #f8fff9;
display: flex;
align-items: center;
}
}
.test-result-section {
flex: 1.5;
min-width: 0;
background: white;
border-radius: 6px; border-radius: 6px;
padding: 15px; border: 1px solid #e8f5e8;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
h6 { .file-name {
font-size: 15px; font-weight: 500;
margin-bottom: 12px; text-overflow: ellipsis;
color: #262626; overflow: hidden;
white-space: nowrap;
max-width: 70%;
color: #333;
font-size: 13px;
}
.file-size {
color: #6b7280;
font-size: 12px;
font-weight: 500; font-weight: 500;
} }
}
}
.result-item { .test-button-wrapper {
margin-bottom: 12px; text-align: center;
margin-top: 16px;
padding: 12px 20px;
background: #f8fff9;
border-radius: 8px;
border: 1px solid #e8f5e8;
&.time-item { .t-button {
color: #666; min-width: 100px;
font-size: 12px; height: 32px;
text-align: right; font-weight: 500;
} font-size: 13px;
}
}
label { .test-result {
display: block; background: white;
font-weight: 500; border-radius: 10px;
margin-bottom: 4px; padding: 20px;
color: #666; border: 1px solid #e8f5e8;
} box-shadow: 0 2px 8px rgba(7, 192, 95, 0.08);
.result-content { h6 {
background: #f5f5f5; font-size: 15px;
padding: 8px 10px; margin-bottom: 16px;
border-radius: 4px; color: #07c05f;
color: #262626; font-weight: 600;
white-space: pre-wrap; padding-bottom: 8px;
max-height: 120px; border-bottom: 2px solid #f0fdf4;
overflow-y: auto; }
}
.result-item {
margin-bottom: 16px;
label {
display: block;
font-weight: 600;
margin-bottom: 8px;
color: #333;
font-size: 14px;
}
.result-text {
background: #f8fff9;
padding: 12px 16px;
border-radius: 8px;
color: #333;
white-space: pre-wrap;
max-height: 120px;
overflow-y: auto;
border: 1px solid #e8f5e8;
font-size: 13px;
line-height: 1.5;
} }
} }
.image-preview-container { .result-time {
border: 2px dashed #ffcba4; text-align: right;
border-radius: 8px; color: #6b7280;
background: #fffbf7; font-size: 12px;
padding: 10px; margin-top: 12px;
text-align: center; padding: 8px 12px;
background: #f8f9fa;
.image-preview { border-radius: 6px;
margin-bottom: 10px; border: 1px solid #e9ecef;
img {
max-width: 100%;
max-height: 200px;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 2px 8px rgba(255, 107, 53, 0.15);
}
}
.image-info {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 5px;
font-size: 12px;
color: #d46b08;
span {
&:first-child {
font-weight: 500;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 70%;
}
}
}
} }
.result-error { .result-error {
color: #d54941; color: #e34d59;
.error-content { .error-msg {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
background: #fff2f0; background: #fff2f0;
padding: 10px; padding: 12px 16px;
border-radius: 4px; border-radius: 8px;
border-left: 3px solid #d54941; border: 1px solid #ffccc7;
font-size: 13px;
line-height: 1.4;
} }
} }
} }