Dockerfile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. libglib2.0-0 \
  20. && rm -rf /var/lib/apt/lists/*
  21. # Set Python 3.10 as the default python3
  22. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
  23. # Create a virtual environment for MinerU
  24. RUN python3 -m venv /opt/mineru_venv
  25. # Activate the virtual environment and install necessary Python packages
  26. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  27. pip3 install --upgrade pip && \
  28. wget https://gitee.com/myhloli/MinerU/raw/master/requirements-docker.txt && \
  29. pip3 install -r requirements-docker.txt --extra-index-url https://wheels.myhloli.com -i https://mirrors.aliyun.com/pypi/simple && \
  30. pip3 install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/"
  31. # Copy the configuration file template and install magic-pdf latest
  32. RUN /bin/bash -c "wget https://gitee.com/myhloli/MinerU/raw/master/magic-pdf.template.json && \
  33. cp magic-pdf.template.json /root/magic-pdf.json && \
  34. source /opt/mineru_venv/bin/activate && \
  35. pip3 install -U magic-pdf"
  36. # Download models and update the configuration file
  37. RUN /bin/bash -c "pip3 install modelscope && \
  38. wget https://gitee.com/myhloli/MinerU/raw/master/scripts/download_models.py && \
  39. python3 download_models.py && \
  40. sed -i 's|cpu|cuda|g' /root/magic-pdf.json"
  41. # Set the entry point to activate the virtual environment and run the command line tool
  42. ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]