Dockerfile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Use the official Ubuntu base image
  2. FROM ubuntu:latest
  3. # ENV http_proxy http://127.0.0.1:7890
  4. # ENV https_proxy http://127.0.0.1:7890
  5. # Set environment variables to non-interactive to avoid prompts during installation
  6. ENV DEBIAN_FRONTEND=noninteractive
  7. ENV LANG C.UTF-8
  8. # ADD sources.list /etc/apt
  9. # RUN apt-get clean
  10. # Update the package list and install necessary packages
  11. RUN apt-get -q update \
  12. && apt-get -q install -y --no-install-recommends \
  13. apt-utils \
  14. bats \
  15. build-essential
  16. RUN apt-get update && apt-get install -y vim net-tools procps lsof curl wget iputils-ping telnet lrzsz git
  17. RUN apt-get update && \
  18. apt-get install -y \
  19. software-properties-common && \
  20. add-apt-repository ppa:deadsnakes/ppa && \
  21. apt-get update && \
  22. apt-get install -y \
  23. python3.10 \
  24. python3.10-venv \
  25. python3.10-distutils \
  26. python3-pip \
  27. wget \
  28. git \
  29. libgl1 \
  30. libglib2.0-0 \
  31. && rm -rf /var/lib/apt/lists/*
  32. # RUN unset http_proxy && unset https_proxy
  33. # Set Python 3.10 as the default python3
  34. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
  35. # Create a virtual environment for MinerU
  36. RUN python3 -m venv /opt/mineru_venv
  37. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
  38. # Activate the virtual environment and install necessary Python packages
  39. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  40. pip install --upgrade pip && \
  41. pip install magic-pdf[full] --extra-index-url https://myhloli.github.io/wheels/ --no-cache-dir"
  42. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  43. pip install fastapi uvicorn python-multipart --no-cache-dir"
  44. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  45. pip uninstall paddlepaddle -y"
  46. RUN /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  47. python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ --no-cache-dir"
  48. # Copy the configuration file template and set up the model directory
  49. COPY magic-pdf.template.json /root/magic-pdf.json
  50. ADD models /opt/models
  51. ADD .paddleocr /root/.paddleocr
  52. ADD app.py /root/app.py
  53. WORKDIR /root
  54. # Set the models directory in the configuration file (adjust the path as needed)
  55. RUN sed -i 's|/tmp/models|/opt/models|g' /root/magic-pdf.json
  56. # Create the models directory
  57. # RUN mkdir -p /opt/models
  58. # Set the entry point to activate the virtual environment and run the command line tool
  59. # ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\" && python3 app.py", "--"]
  60. # Expose the port that FastAPI will run on
  61. EXPOSE 8000
  62. # Command to run FastAPI using Uvicorn, pointing to app.py and binding to 0.0.0.0:8000
  63. CMD ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && uvicorn app:app --host 0.0.0.0 --port 8000"]