Dockerfile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Use the official Ubuntu base image
  2. FROM ubuntu:latest
  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. pip install --upgrade pip && \
  28. pip install magic-pdf[full-cpu] detectron2 --extra-index-url https://myhloli.github.io/wheels/"
  29. # Copy the configuration file template and set up the model directory
  30. COPY magic-pdf.template.json /root/magic-pdf.json
  31. # Set the models directory in the configuration file (adjust the path as needed)
  32. RUN sed -i 's|/tmp/models|/opt/models|g' /root/magic-pdf.json
  33. # Create the models directory
  34. RUN mkdir -p /opt/models
  35. # Set the entry point to activate the virtual environment and run the command line tool
  36. ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\"", "--"]