50 lines
1.5 KiB
Docker
50 lines
1.5 KiB
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
COPY requirements.txt /app/requirements.txt
|
|
# 大型识别组件下载时可能短暂断线。优先使用构建参数指定的源,
|
|
# 失败后自动切换到官方 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 \
|
|
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
|
|
COPY duty /app/duty
|
|
COPY dist /app/dist
|
|
COPY config.toml /app/config.toml
|
|
COPY seed /app/seed
|
|
|
|
RUN mkdir -p /app/data
|
|
|
|
ENV WORKLOG_HOST=0.0.0.0 \
|
|
WORKLOG_PORT=37777 \
|
|
WORKLOG_DB=/app/data/worklog.db \
|
|
WORKLOG_FRONTEND=/app/dist
|
|
|
|
EXPOSE 37777
|
|
|
|
VOLUME /app/data
|
|
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["python", "-m", "server.main"]
|