feat: enhance Dockerfile and build scripts for customizable APT mirror

- Added support for customizable APT mirror in the Dockerfile for the docreader service, allowing users to specify a mirror via build arguments.
- Updated docker-compose.yml to pass the APT_MIRROR argument during the build process.
- Modified build_images.sh script to include the APT_MIRROR argument when building the docreader image.
- Updated .gitignore to exclude .cursor/ directory.

This update improves flexibility in package management during the image build process.
This commit is contained in:
wizardchen
2026-02-28 16:06:54 +08:00
committed by lyingbug
parent 469f320d10
commit 6d88619869
5 changed files with 16 additions and 7 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
# 忽略.env文件和其他包含敏感信息的配置文件
.env
.env.lite
.cursor/
# 但不忽略示例文件
!.env.example
*.pem

View File

@@ -145,6 +145,8 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.docreader
args:
- APT_MIRROR=${APT_MIRROR:-}
container_name: WeKnora-docreader
ports:
- "${DOCREADER_PORT:-50051}:50051"

View File

@@ -3,9 +3,11 @@
# =========================
FROM python:3.10.18-bookworm 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
ARG APT_MIRROR=""
RUN if [ -n "$APT_MIRROR" ]; then \
sed -i "s@http://deb.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources && \
sed -i "s@http://security.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources; \
fi
WORKDIR /app
@@ -67,9 +69,11 @@ RUN chmod +x docreader/scripts/generate_proto.sh && \
# =========================
FROM python:3.10.18-bookworm 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
ARG APT_MIRROR=""
RUN if [ -n "$APT_MIRROR" ]; then \
sed -i "s@http://deb.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources && \
sed -i "s@http://security.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources; \
fi
WORKDIR /app

View File

@@ -10,7 +10,8 @@ export default defineConfig({
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@vue-office/pptx': '@vue-office/pptx/lib/index.js',
},
},
server: {

View File

@@ -165,6 +165,7 @@ build_docreader_image() {
--platform $PLATFORM \
--build-arg PLATFORM=$PLATFORM \
--build-arg TARGETARCH=$TARGETARCH \
--build-arg APT_MIRROR=${APT_MIRROR:-} \
-f docker/Dockerfile.docreader \
-t wechatopenai/weknora-docreader:latest \
.