Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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://github.com/opendatalab/MinerU/raw/master/docker/global/requirements.txt -O requirements.txt && \
  29. pip3 install -r requirements.txt"
  30. # Copy the configuration file template and install magic-pdf latest
  31. RUN /bin/bash -c "wget https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json && \
  32. cp magic-pdf.template.json /root/magic-pdf.json && \
  33. source /opt/mineru_venv/bin/activate && \
  34. pip3 install -U magic-pdf"
  35. # Download models and update the configuration file
  36. RUN /bin/bash -c "pip3 install huggingface_hub && \
  37. wget https://github.com/opendatalab/MinerU/raw/master/scripts/download_models_hf.py -O download_models.py && \
  38. python3 download_models.py && \
  39. sed -i 's|cpu|cuda|g' /root/magic-pdf.json"
  40. # Set the entry point to activate the virtual environment and run the command line tool
  41. ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]