This commit is contained in:
2025-11-01 16:07:12 +08:00
parent c347b12ea7
commit a5572a157e
5 changed files with 237 additions and 36 deletions

View File

@@ -87,36 +87,34 @@ WORKDIR /app
# 设置维护者信息
LABEL maintainer="digital-archive-team"
# 清理包缓存并更新索引
RUN rm -rf /var/cache/apk/* && \
apk update --no-cache && \
apk upgrade --no-cache
# 配置阿里云Alpine镜像源最快
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
sed -i 's/https/http/g' /etc/apk/repositories
# 安装基础必需包(分步骤确保稳定性
RUN apk add --no-cache ca-certificates
# 更新包索引(使用国内镜像
RUN apk update --no-cache
RUN apk add --no-cache curl
# 一次性安装所有基础包(减少层数和下载次数)
RUN apk add --no-cache \
ca-certificates \
curl \
bash \
tini \
&& rm -rf /var/cache/apk/*
RUN apk add --no-cache bash
# Tesseract OCR 安装(完全独立,失败不影响主应用)
# 使用清华镜像源作为备选
RUN ( \
echo "http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.18/main" > /etc/apk/repositories && \
echo "http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.18/community" >> /etc/apk/repositories && \
apk update --no-cache && \
apk add --no-cache tesseract tesseract-ocr \
) 2>/dev/null || ( \
echo "Tesseract installation failed - will use OCR service fallback" && \
true \
)
RUN apk add --no-cache tini
# 清理缓存
RUN rm -rf /var/cache/apk/*
# 尝试安装Tesseract OCR完全可选失败不影响构建
RUN apk add --no-cache tesseract tesseract-ocr 2>/dev/null || \
(echo "Tesseract installation failed - using OCR service fallback" && true)
# 尝试安装中文语言包
RUN apk add --no-cache tesseract-data-chi_sim tesseract-data-chi_tra 2>/dev/null || \
(echo "Chinese language packs installation failed" && true)
# 尝试安装英文语言包
RUN apk add --no-cache tesseract-data-eng 2>/dev/null || \
(echo "English language pack installation failed" && true)
# 最终清理
# 清理所有缓存
RUN rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
# 验证关键组件