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

Dockerfile 7.4KB

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