UnisMindMap/docker/china/Dockerfile.noyolo

69 lines
2.5 KiB
Docker
Raw Normal View History

# Build stage
FROM docker.m.daocloud.io/ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y \
build-essential curl wget git fontconfig libgl1 \
libreoffice-writer libreoffice-core \
fonts-noto-core fonts-noto-cjk \
python3 python3-pip python3-venv && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
fc-cache -fv && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
# --- 核心修复:显式安装 torch 和相关依赖 ---
RUN pip3 install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/
# 1. 先安装 torch (CPU版如果需要GPU则去掉 -f 指向)
RUN pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu
# 2. 安装项目及其余依赖
RUN pip3 install -e ".[full]" -i https://mirrors.aliyun.com/pypi/simple/
RUN pip3 install uvicorn fastapi python-multipart -i https://mirrors.aliyun.com/pypi/simple/
# 构建前端
WORKDIR /app/web_ui
RUN npm install && npm run build
WORKDIR /app
RUN mkdir -p mineru/cli/static/web && cp -r web_ui/dist/* mineru/cli/static/web/
# ==========================================
# Runtime stage
# ==========================================
FROM docker.m.daocloud.io/ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y libgl1 libreoffice-writer libreoffice-core \
fonts-noto-core fonts-noto-cjk fontconfig python3 python3-pip && \
fc-cache -fv && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 拷贝环境
COPY --from=builder /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /app /app
# 注入配置文件
RUN mkdir -p /root/.config/mineru && \
echo '{"models-dir": "/root/.cache/modelscope/hub/models"}' > /root/magic-pdf.json
EXPOSE 8000
# 使用环境变量 + 显式参数启动
ENTRYPOINT ["/bin/sh", "-c", "export MINERU_CONFIG_PATH=/root/magic-pdf.json && export MINERU_MODEL_SOURCE=local && export PYTHONPATH=/app && python3 -m mineru.cli.fast_api --host 0.0.0.0 --port 8000"]