延迟加载活动照片并增强镜像构建稳定性
This commit is contained in:
+18
-3
@@ -3,11 +3,26 @@ FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
# 国内服务器从默认PyPI下载大型识别组件可能超时;可用构建参数覆盖源。
|
||||
# 大型识别组件下载时可能短暂断线。优先使用构建参数指定的源,
|
||||
# 失败后自动切换到官方 PyPI,并保留 BuildKit 下载缓存。
|
||||
ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
|
||||
ARG PIP_FALLBACK_INDEX_URL=https://pypi.org/simple/
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PIP_DEFAULT_TIMEOUT=300 \
|
||||
PIP_RETRIES=10 \
|
||||
PIP_PROGRESS_BAR=off
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python -m pip install --disable-pip-version-check --retries 3 --timeout 120 \
|
||||
--index-url "${PIP_INDEX_URL}" -r /app/requirements.txt
|
||||
set -eu; \
|
||||
for index_url in "${PIP_INDEX_URL}" "${PIP_FALLBACK_INDEX_URL}"; do \
|
||||
echo "Installing Python dependencies from ${index_url}"; \
|
||||
if python -m pip install --prefer-binary --no-input \
|
||||
--retries "${PIP_RETRIES}" --timeout "${PIP_DEFAULT_TIMEOUT}" \
|
||||
--index-url "${index_url}" -r /app/requirements.txt; then \
|
||||
exit 0; \
|
||||
fi; \
|
||||
echo "Dependency download failed from ${index_url}; trying the next source"; \
|
||||
done; \
|
||||
exit 1
|
||||
RUN python -c "import PIL, rapidocr, onnxruntime, cv2"
|
||||
|
||||
COPY server /app/server
|
||||
|
||||
Reference in New Issue
Block a user