您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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