Dockerfile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Use the official Ubuntu base image
  2. FROM swr.cn-central-221.ovaijisuan.com/mindformers/mindformers1.2_mindspore2.3:20240722
  3. USER root
  4. # Set environment variables to non-interactive to avoid prompts during installation
  5. ENV DEBIAN_FRONTEND=noninteractive
  6. # Update the package list and install necessary packages
  7. RUN apt-get update && \
  8. apt-get install -y \
  9. software-properties-common && \
  10. add-apt-repository -y ppa:deadsnakes/ppa && \
  11. apt-get update && \
  12. apt-get install -y \
  13. python3.10 \
  14. python3.10-venv \
  15. python3.10-distutils \
  16. python3.10-dev \
  17. python3-pip \
  18. wget \
  19. git \
  20. libgl1 \
  21. libglib2.0-0 \
  22. && rm -rf /var/lib/apt/lists/*
  23. # Set Python 3.10 as the default python3
  24. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
  25. # Create a virtual environment for MinerU
  26. RUN python3 -m venv /opt/mineru_venv
  27. # Copy the configuration file template and install magic-pdf latest
  28. RUN /bin/bash -c "wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/magic-pdf.template.json && \
  29. cp magic-pdf.template.json /root/magic-pdf.json && \
  30. source /opt/mineru_venv/bin/activate && \
  31. pip3 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple && \
  32. pip3 install torch==2.3.1 torchvision==0.18.1 -i https://mirrors.aliyun.com/pypi/simple && \
  33. pip3 install -U magic-pdf[full] -i https://mirrors.aliyun.com/pypi/simple && \
  34. wget https://gitee.com/ascend/pytorch/releases/download/v6.0.rc2-pytorch2.3.1/torch_npu-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl && \
  35. pip3 install torch_npu-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"
  36. # Download models and update the configuration file
  37. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  38. pip3 install modelscope -i https://mirrors.aliyun.com/pypi/simple && \
  39. wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py -O download_models.py && \
  40. python3 download_models.py && \
  41. sed -i 's|cpu|npu|g' /root/magic-pdf.json"
  42. # Set the entry point to activate the virtual environment and run the command line tool
  43. ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]