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