Dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Use the official Ubuntu base image
  2. FROM ubuntu:22.04
  3. # Set environment variables to non-interactive to avoid prompts during installation
  4. ENV DEBIAN_FRONTEND=noninteractive
  5. # Update the package list and install necessary packages
  6. RUN apt-get update && \
  7. apt-get install -y \
  8. software-properties-common && \
  9. add-apt-repository ppa:deadsnakes/ppa && \
  10. apt-get update && \
  11. apt-get install -y \
  12. python3.10 \
  13. python3.10-venv \
  14. python3.10-distutils \
  15. python3-pip \
  16. wget \
  17. git \
  18. libgl1 \
  19. libreoffice \
  20. fonts-noto-cjk \
  21. fonts-wqy-zenhei \
  22. fonts-wqy-microhei \
  23. ttf-mscorefonts-installer \
  24. fontconfig \
  25. libglib2.0-0 \
  26. libxrender1 \
  27. libsm6 \
  28. libxext6 \
  29. poppler-utils \
  30. && rm -rf /var/lib/apt/lists/*
  31. # Set Python 3.10 as the default python3
  32. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
  33. # Create a virtual environment for MinerU
  34. RUN python3 -m venv /opt/mineru_venv
  35. # Copy the configuration file template and install magic-pdf latest
  36. RUN /bin/bash -c "wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/magic-pdf.template.json && \
  37. cp magic-pdf.template.json /root/magic-pdf.json && \
  38. source /opt/mineru_venv/bin/activate && \
  39. pip3 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple && \
  40. pip3 install -U magic-pdf[full] -i https://mirrors.aliyun.com/pypi/simple"
  41. # Download models and update the configuration file
  42. RUN /bin/bash -c "pip3 install modelscope -i https://mirrors.aliyun.com/pypi/simple && \
  43. wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py -O download_models.py && \
  44. python3 download_models.py && \
  45. sed -i 's|cpu|cuda|g' /root/magic-pdf.json"
  46. # Set the entry point to activate the virtual environment and run the command line tool
  47. ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]