Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Dockerfile 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # base stage
  2. FROM ubuntu:22.04 AS base
  3. USER root
  4. SHELL ["/bin/bash", "-c"]
  5. ARG NEED_MIRROR=0
  6. ARG LIGHTEN=0
  7. ENV LIGHTEN=${LIGHTEN}
  8. WORKDIR /ragflow
  9. # Copy models downloaded via download_deps.py
  10. RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
  11. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
  12. cp /huggingface.co/InfiniFlow/huqie/huqie.txt.trie /ragflow/rag/res/ && \
  13. tar --exclude='.*' -cf - \
  14. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  15. /huggingface.co/InfiniFlow/deepdoc \
  16. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  17. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
  18. if [ "$LIGHTEN" != "1" ]; then \
  19. (tar -cf - \
  20. /huggingface.co/BAAI/bge-large-zh-v1.5 \
  21. /huggingface.co/maidalun1020/bce-embedding-base_v1 \
  22. | tar -xf - --strip-components=2 -C /root/.ragflow) \
  23. fi
  24. # https://github.com/chrismattmann/tika-python
  25. # This is the only way to run python-tika without internet access. Without this set, the default is to check the tika version and pull latest every time from Apache.
  26. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps \
  27. cp -r /deps/nltk_data /root/ && \
  28. cp /deps/tika-server-standard-3.0.0.jar /deps/tika-server-standard-3.0.0.jar.md5 /ragflow/ && \
  29. cp /deps/cl100k_base.tiktoken /ragflow/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
  30. ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard-3.0.0.jar"
  31. ENV DEBIAN_FRONTEND=noninteractive
  32. # Setup apt
  33. # Python package and implicit dependencies:
  34. # opencv-python: libglib2.0-0 libglx-mesa0 libgl1
  35. # aspose-slides: pkg-config libicu-dev libgdiplus libssl1.1_1.1.1f-1ubuntu2_amd64.deb
  36. # python-pptx: default-jdk tika-server-standard-3.0.0.jar
  37. # selenium: libatk-bridge2.0-0 chrome-linux64-121-0-6167-85
  38. # Building C extensions: libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev
  39. RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
  40. if [ "$NEED_MIRROR" == "1" ]; then \
  41. sed -i 's|http://ports.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list; \
  42. sed -i 's|http://archive.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list; \
  43. fi; \
  44. rm -f /etc/apt/apt.conf.d/docker-clean && \
  45. echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \
  46. chmod 1777 /tmp && \
  47. apt update && \
  48. apt --no-install-recommends install -y ca-certificates && \
  49. apt update && \
  50. apt install -y libglib2.0-0 libglx-mesa0 libgl1 && \
  51. apt install -y pkg-config libicu-dev libgdiplus && \
  52. apt install -y default-jdk && \
  53. apt install -y libatk-bridge2.0-0 && \
  54. apt install -y libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev && \
  55. apt install -y libjemalloc-dev && \
  56. apt install -y python3-pip pipx nginx unzip curl wget git vim less
  57. RUN if [ "$NEED_MIRROR" == "1" ]; then \
  58. pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
  59. pip3 config set global.trusted-host mirrors.aliyun.com; \
  60. mkdir -p /etc/uv && \
  61. echo "[[index]]" > /etc/uv/uv.toml && \
  62. echo 'url = "https://mirrors.aliyun.com/pypi/simple"' >> /etc/uv/uv.toml && \
  63. echo "default = true" >> /etc/uv/uv.toml; \
  64. fi; \
  65. pipx install uv
  66. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  67. ENV PATH=/root/.local/bin:$PATH
  68. # nodejs 12.22 on Ubuntu 22.04 is too old
  69. RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
  70. curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
  71. apt purge -y nodejs npm cargo && \
  72. apt autoremove -y && \
  73. apt update && \
  74. apt install -y nodejs
  75. # A modern version of cargo is needed for the latest version of the Rust compiler.
  76. RUN apt update && apt install -y curl build-essential \
  77. && if [ "$NEED_MIRROR" == "1" ]; then \
  78. # Use TUNA mirrors for rustup/rust dist files
  79. export RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"; \
  80. export RUSTUP_UPDATE_ROOT="https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup"; \
  81. echo "Using TUNA mirrors for Rustup."; \
  82. fi; \
  83. # Force curl to use HTTP/1.1
  84. curl --proto '=https' --tlsv1.2 --http1.1 -sSf https://sh.rustup.rs | bash -s -- -y --profile minimal \
  85. && echo 'export PATH="/root/.cargo/bin:${PATH}"' >> /root/.bashrc
  86. ENV PATH="/root/.cargo/bin:${PATH}"
  87. RUN cargo --version && rustc --version
  88. # Add msssql ODBC driver
  89. # macOS ARM64 environment, install msodbcsql18.
  90. # general x86_64 environment, install msodbcsql17.
  91. RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
  92. curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
  93. curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
  94. apt update && \
  95. arch="$(uname -m)"; \
  96. if [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then \
  97. # ARM64 (macOS/Apple Silicon or Linux aarch64)
  98. ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql18; \
  99. else \
  100. # x86_64 or others
  101. ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql17; \
  102. fi || \
  103. { echo "Failed to install ODBC driver"; exit 1; }
  104. # Add dependencies of selenium
  105. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chrome-linux64-121-0-6167-85,target=/chrome-linux64.zip \
  106. unzip /chrome-linux64.zip && \
  107. mv chrome-linux64 /opt/chrome && \
  108. ln -s /opt/chrome/chrome /usr/local/bin/
  109. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chromedriver-linux64-121-0-6167-85,target=/chromedriver-linux64.zip \
  110. unzip -j /chromedriver-linux64.zip chromedriver-linux64/chromedriver && \
  111. mv chromedriver /usr/local/bin/ && \
  112. rm -f /usr/bin/google-chrome
  113. # https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
  114. # aspose-slides on linux/arm64 is unavailable
  115. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps \
  116. if [ "$(uname -m)" = "x86_64" ]; then \
  117. dpkg -i /deps/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
  118. elif [ "$(uname -m)" = "aarch64" ]; then \
  119. dpkg -i /deps/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
  120. fi
  121. # builder stage
  122. FROM base AS builder
  123. USER root
  124. WORKDIR /ragflow
  125. # install dependencies from uv.lock file
  126. COPY pyproject.toml uv.lock ./
  127. # https://github.com/astral-sh/uv/issues/10462
  128. # uv records index url into uv.lock but doesn't failover among multiple indexes
  129. RUN --mount=type=cache,id=ragflow_uv,target=/root/.cache/uv,sharing=locked \
  130. if [ "$NEED_MIRROR" == "1" ]; then \
  131. sed -i 's|pypi.org|mirrors.aliyun.com/pypi|g' uv.lock; \
  132. else \
  133. sed -i 's|mirrors.aliyun.com/pypi|pypi.org|g' uv.lock; \
  134. fi; \
  135. if [ "$LIGHTEN" == "1" ]; then \
  136. uv sync --python 3.10 --frozen; \
  137. else \
  138. uv sync --python 3.10 --frozen --all-extras; \
  139. fi
  140. COPY web web
  141. COPY docs docs
  142. RUN --mount=type=cache,id=ragflow_npm,target=/root/.npm,sharing=locked \
  143. cd web && npm install && npm run build
  144. COPY .git /ragflow/.git
  145. RUN version_info=$(git describe --tags --match=v* --first-parent --always); \
  146. if [ "$LIGHTEN" == "1" ]; then \
  147. version_info="$version_info slim"; \
  148. else \
  149. version_info="$version_info full"; \
  150. fi; \
  151. echo "RAGFlow version: $version_info"; \
  152. echo $version_info > /ragflow/VERSION
  153. # production stage
  154. FROM base AS production
  155. USER root
  156. WORKDIR /ragflow
  157. # Copy Python environment and packages
  158. ENV VIRTUAL_ENV=/ragflow/.venv
  159. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  160. ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
  161. ENV PYTHONPATH=/ragflow/
  162. COPY web web
  163. COPY api api
  164. COPY conf conf
  165. COPY deepdoc deepdoc
  166. COPY rag rag
  167. COPY agent agent
  168. COPY graphrag graphrag
  169. COPY agentic_reasoning agentic_reasoning
  170. COPY pyproject.toml uv.lock ./
  171. COPY mcp mcp
  172. COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
  173. COPY docker/entrypoint.sh ./
  174. RUN chmod +x ./entrypoint*.sh
  175. # Copy compiled web pages
  176. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  177. COPY --from=builder /ragflow/VERSION /ragflow/VERSION
  178. ENTRYPOINT ["./entrypoint.sh"]