Dockerfile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. ENV LANG C.UTF-8
  6. # Update the package list and install necessary packages
  7. RUN apt-get -q update && \
  8. apt-get -q install -y --no-install-recommends \
  9. build-essential \
  10. software-properties-common \
  11. # gpg \
  12. # && add-apt-repository ppa:deadsnakes/ppa \
  13. && apt-get update \
  14. && apt-get install -y \
  15. python3.10 \
  16. python3.10-venv \
  17. python3.10-distutils \
  18. python3-pip \
  19. wget \
  20. git \
  21. libgl1 \
  22. libglib2.0-0 \
  23. && apt-get clean \
  24. && rm -rf /var/lib/apt/lists/*
  25. # Set Python 3.10 as the default python3
  26. RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
  27. # Create a virtual environment for MinerU and install packages
  28. RUN python3 -m venv /opt/mineru_venv && \
  29. pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
  30. /bin/bash -c "source /opt/mineru_venv/bin/activate && \
  31. pip install --upgrade pip && \
  32. pip install magic-pdf[full] --extra-index-url https://myhloli.github.io/wheels/ --no-cache-dir && \
  33. pip install fastapi uvicorn python-multipart --no-cache-dir && \
  34. pip uninstall paddlepaddle -y && \
  35. pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ --no-cache-dir"
  36. # Copy the configuration file template and set up the model directory
  37. COPY models/models /opt/models
  38. COPY layoutreader /opt/layoutreader
  39. COPY .paddleocr /root/.paddleocr
  40. COPY app.py /root/app.py
  41. COPY magic-pdf.json /root/magic-pdf.json
  42. WORKDIR /root
  43. # Create the models directory
  44. # RUN mkdir -p /opt/models
  45. # Set the entry point to activate the virtual environment and run the command line tool
  46. # ENTRYPOINT ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && exec \"$@\" && python3 app.py", "--"]
  47. # Expose the port that FastAPI will run on
  48. EXPOSE 8000
  49. # Command to run FastAPI using Uvicorn, pointing to app.py and binding to 0.0.0.0:8000
  50. CMD ["/bin/bash", "-c", "source /opt/mineru_venv/bin/activate && uvicorn app:app --host 0.0.0.0 --port 8000"]