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.

Dockerfile 8.1KB

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