Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Dockerfile 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. tar --exclude='.*' -cf - \
  13. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  14. /huggingface.co/InfiniFlow/deepdoc \
  15. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  16. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
  17. if [ "$LIGHTEN" != "1" ]; then \
  18. (tar -cf - \
  19. /huggingface.co/BAAI/bge-large-zh-v1.5 \
  20. /huggingface.co/BAAI/bge-reranker-v2-m3 \
  21. /huggingface.co/maidalun1020/bce-embedding-base_v1 \
  22. /huggingface.co/maidalun1020/bce-reranker-base_v1 \
  23. | tar -xf - --strip-components=2 -C /root/.ragflow) \
  24. fi
  25. # https://github.com/chrismattmann/tika-python
  26. # 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.
  27. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps \
  28. cp -r /deps/nltk_data /root/ && \
  29. cp /deps/tika-server-standard-3.0.0.jar /deps/tika-server-standard-3.0.0.jar.md5 /ragflow/ && \
  30. cp /deps/cl100k_base.tiktoken /ragflow/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
  31. ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard-3.0.0.jar"
  32. ENV DEBIAN_FRONTEND=noninteractive
  33. # Setup apt
  34. # Python package and implicit dependencies:
  35. # opencv-python: libglib2.0-0 libglx-mesa0 libgl1
  36. # aspose-slides: pkg-config libicu-dev libgdiplus libssl1.1_1.1.1f-1ubuntu2_amd64.deb
  37. # python-pptx: default-jdk tika-server-standard-3.0.0.jar
  38. # selenium: libatk-bridge2.0-0 chrome-linux64-121-0-6167-85
  39. # Building C extensions: libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev
  40. RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
  41. if [ "$NEED_MIRROR" == "1" ]; then \
  42. sed -i 's|http://archive.ubuntu.com|https://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 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://pypi.tuna.tsinghua.edu.cn/simple && \
  58. pip3 config set global.trusted-host pypi.tuna.tsinghua.edu.cn; \
  59. fi; \
  60. pipx install poetry; \
  61. if [ "$NEED_MIRROR" == "1" ]; then \
  62. pipx inject poetry poetry-plugin-pypi-mirror; \
  63. fi
  64. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  65. ENV PATH=/root/.local/bin:$PATH
  66. # Configure Poetry
  67. ENV POETRY_NO_INTERACTION=1
  68. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  69. ENV POETRY_VIRTUALENVS_CREATE=true
  70. ENV POETRY_REQUESTS_TIMEOUT=15
  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 && \
  75. apt autoremove && \
  76. apt update && \
  77. apt install -y nodejs cargo
  78. # Add msssql ODBC driver
  79. # macOS ARM64 environment, install msodbcsql18.
  80. # general x86_64 environment, install msodbcsql17.
  81. RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
  82. curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
  83. curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
  84. apt update && \
  85. if [ -n "$ARCH" ] && [ "$ARCH" = "arm64" ]; then \
  86. # MacOS ARM64
  87. ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql18; \
  88. else \
  89. # (x86_64)
  90. ACCEPT_EULA=Y apt install -y unixodbc-dev msodbcsql17; \
  91. fi || \
  92. { echo "Failed to install ODBC driver"; exit 1; }
  93. # Add dependencies of selenium
  94. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chrome-linux64-121-0-6167-85,target=/chrome-linux64.zip \
  95. unzip /chrome-linux64.zip && \
  96. mv chrome-linux64 /opt/chrome && \
  97. ln -s /opt/chrome/chrome /usr/local/bin/
  98. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chromedriver-linux64-121-0-6167-85,target=/chromedriver-linux64.zip \
  99. unzip -j /chromedriver-linux64.zip chromedriver-linux64/chromedriver && \
  100. mv chromedriver /usr/local/bin/ && \
  101. rm -f /usr/bin/google-chrome
  102. # https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
  103. # aspose-slides on linux/arm64 is unavailable
  104. RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps \
  105. if [ "$(uname -m)" = "x86_64" ]; then \
  106. dpkg -i /deps/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
  107. elif [ "$(uname -m)" = "aarch64" ]; then \
  108. dpkg -i /deps/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
  109. fi
  110. # builder stage
  111. FROM base AS builder
  112. USER root
  113. WORKDIR /ragflow
  114. # install dependencies from poetry.lock file
  115. COPY pyproject.toml poetry.toml poetry.lock ./
  116. RUN --mount=type=cache,id=ragflow_poetry,target=/root/.cache/pypoetry,sharing=locked \
  117. if [ "$NEED_MIRROR" == "1" ]; then \
  118. export POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/; \
  119. fi; \
  120. if [ "$LIGHTEN" == "1" ]; then \
  121. poetry install --no-root; \
  122. else \
  123. poetry install --no-root --with=full; \
  124. fi
  125. COPY web web
  126. COPY docs docs
  127. RUN --mount=type=cache,id=ragflow_npm,target=/root/.npm,sharing=locked \
  128. cd web && npm install --force && npm run build
  129. COPY .git /ragflow/.git
  130. RUN version_info=$(git describe --tags --match=v* --first-parent --always); \
  131. if [ "$LIGHTEN" == "1" ]; then \
  132. version_info="$version_info slim"; \
  133. else \
  134. version_info="$version_info full"; \
  135. fi; \
  136. echo "RAGFlow version: $version_info"; \
  137. echo $version_info > /ragflow/VERSION
  138. # production stage
  139. FROM base AS production
  140. USER root
  141. WORKDIR /ragflow
  142. # Copy Python environment and packages
  143. ENV VIRTUAL_ENV=/ragflow/.venv
  144. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  145. ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
  146. ENV PYTHONPATH=/ragflow/
  147. COPY web web
  148. COPY api api
  149. COPY conf conf
  150. COPY deepdoc deepdoc
  151. COPY rag rag
  152. COPY agent agent
  153. COPY graphrag graphrag
  154. COPY pyproject.toml poetry.toml poetry.lock ./
  155. COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
  156. COPY docker/entrypoint.sh ./entrypoint.sh
  157. RUN chmod +x ./entrypoint.sh
  158. # Copy compiled web pages
  159. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  160. COPY --from=builder /ragflow/VERSION /ragflow/VERSION
  161. ENTRYPOINT ["./entrypoint.sh"]