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.3KB

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