You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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