mineru / Dockerfile
ASEM12345's picture
Upload folder using huggingface_hub
00f9855 verified
# MinerU for HuggingFace Spaces (CPU-only)
# 基于 python:3.11-slim,使用 pipeline 后端运行
FROM python:3.11-slim
# 安装系统依赖和 Nginx
RUN apt-get update && apt-get install -y \
curl \
git \
fonts-noto-core \
fonts-noto-cjk \
fontconfig \
libgl1 \
libglib2.0-0 \
nginx \
&& fc-cache -fv \
&& rm -rf /var/lib/apt/lists/*
# 创建非 root 用户(HF Spaces 要求)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# 安装 MinerU
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir "mineru[core]>=2.7.0"
# 下载模型到本地
RUN mineru-models-download -s huggingface -m all
# 准备 Nginx 权限 (使用 root 身份修改)
USER root
RUN mkdir -p /var/log/nginx /var/lib/nginx /tmp/client_body /tmp/fastcgi_temp /tmp/proxy_temp /tmp/scgi_temp /tmp/uwsgi_temp && \
chmod -R 777 /var/log/nginx /var/lib/nginx /tmp/client_body /tmp/fastcgi_temp /tmp/proxy_temp /tmp/scgi_temp /tmp/uwsgi_temp /etc/nginx/nginx.conf
# 切换回用户
USER user
# 拷贝伪装 UI 与配置
COPY --chown=user index.html ./
COPY --chown=user nginx.conf ./
COPY --chown=user entrypoint.sh ./
RUN chmod +x entrypoint.sh
# 设置环境变量
ENV MINERU_MODEL_SOURCE=local
# HF Spaces 端口暴露给外部
EXPOSE 7860
# 启动脚本
CMD ["./entrypoint.sh"]