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
View File
@@ -1,6 +1,7 @@
# 忽略.env文件和其他包含敏感信息的配置文件 # 忽略.env文件和其他包含敏感信息的配置文件
.env .env
.env.lite .env.lite
.cursor/
# 但不忽略示例文件 # 但不忽略示例文件
!.env.example !.env.example
*.pem *.pem
+2
View File
@@ -145,6 +145,8 @@ services:
build: build:
context: . context: .
dockerfile: docker/Dockerfile.docreader dockerfile: docker/Dockerfile.docreader
args:
- APT_MIRROR=${APT_MIRROR:-}
container_name: WeKnora-docreader container_name: WeKnora-docreader
ports: ports:
- "${DOCREADER_PORT:-50051}:50051" - "${DOCREADER_PORT:-50051}:50051"
+10 -6
View File
@@ -3,9 +3,11 @@
# ========================= # =========================
FROM python:3.10.18-bookworm AS builder FROM python:3.10.18-bookworm AS builder
# 切换 apt 源到清华 ARG APT_MIRROR=""
RUN sed -i 's@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources && \ RUN if [ -n "$APT_MIRROR" ]; then \
sed -i 's@http://security.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources 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 WORKDIR /app
@@ -67,9 +69,11 @@ RUN chmod +x docreader/scripts/generate_proto.sh && \
# ========================= # =========================
FROM python:3.10.18-bookworm AS runner FROM python:3.10.18-bookworm AS runner
# 切换 apt 源到清华 ARG APT_MIRROR=""
RUN sed -i 's@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources && \ RUN if [ -n "$APT_MIRROR" ]; then \
sed -i 's@http://security.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources 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 WORKDIR /app
+2 -1
View File
@@ -10,7 +10,8 @@ export default defineConfig({
], ],
resolve: { resolve: {
alias: { 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: { server: {
+1
View File
@@ -165,6 +165,7 @@ build_docreader_image() {
--platform $PLATFORM \ --platform $PLATFORM \
--build-arg PLATFORM=$PLATFORM \ --build-arg PLATFORM=$PLATFORM \
--build-arg TARGETARCH=$TARGETARCH \ --build-arg TARGETARCH=$TARGETARCH \
--build-arg APT_MIRROR=${APT_MIRROR:-} \
-f docker/Dockerfile.docreader \ -f docker/Dockerfile.docreader \
-t wechatopenai/weknora-docreader:latest \ -t wechatopenai/weknora-docreader:latest \
. .