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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # base stage
  2. FROM ubuntu:24.04 AS base
  3. USER root
  4. ARG ARCH=amd64
  5. ENV LIGHTEN=0
  6. WORKDIR /ragflow
  7. RUN rm -f /etc/apt/apt.conf.d/docker-clean \
  8. && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
  9. RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
  10. apt update && apt-get --no-install-recommends install -y ca-certificates
  11. # If you download Python modules too slow, you can use a pip mirror site to speed up apt and poetry
  12. RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources
  13. ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
  14. RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
  15. apt update && apt install -y curl libpython3-dev nginx libglib2.0-0 libglx-mesa0 pkg-config libicu-dev libgdiplus python3-pip python3-poetry \
  16. && pip3 install --user --break-system-packages poetry-plugin-pypi-mirror --index-url https://pypi.tuna.tsinghua.edu.cn/simple/ \
  17. && rm -rf /var/lib/apt/lists/*
  18. # https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
  19. # aspose-slides on linux/arm64 is unavailable
  20. RUN --mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_amd64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
  21. if [ "${ARCH}" = "amd64" ]; then \
  22. dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
  23. fi
  24. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  25. # Configure Poetry
  26. ENV POETRY_NO_INTERACTION=1
  27. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  28. ENV POETRY_VIRTUALENVS_CREATE=true
  29. ENV POETRY_REQUESTS_TIMEOUT=15
  30. # builder stage
  31. FROM base AS builder
  32. USER root
  33. WORKDIR /ragflow
  34. RUN --mount=type=cache,id=ragflow_builder_apt,target=/var/cache/apt,sharing=locked \
  35. apt update && apt install -y nodejs npm cargo && \
  36. rm -rf /var/lib/apt/lists/*
  37. COPY web web
  38. COPY docs docs
  39. RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
  40. cd web && npm i --force && npm run build
  41. # install dependencies from poetry.lock file
  42. COPY pyproject.toml poetry.toml poetry.lock ./
  43. RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
  44. if [ "$LIGHTEN" -eq 0 ]; then \
  45. poetry install --sync --no-root --with=full; \
  46. else \
  47. poetry install --sync --no-root; \
  48. fi
  49. # production stage
  50. FROM base AS production
  51. USER root
  52. WORKDIR /ragflow
  53. # Install python packages' dependencies
  54. # cv2 requires libGL.so.1
  55. RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=locked \
  56. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  57. rm -rf /var/lib/apt/lists/*
  58. COPY web web
  59. COPY api api
  60. COPY conf conf
  61. COPY deepdoc deepdoc
  62. COPY rag rag
  63. COPY agent agent
  64. COPY graphrag graphrag
  65. COPY pyproject.toml poetry.toml poetry.lock ./
  66. # Copy models downloaded via download_deps.py
  67. RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
  68. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  69. tar --exclude='.*' -cf - \
  70. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  71. /huggingface.co/InfiniFlow/deepdoc \
  72. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  73. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  74. tar -cf - \
  75. /huggingface.co/BAAI/bge-large-zh-v1.5 \
  76. /huggingface.co/BAAI/bge-reranker-v2-m3 \
  77. /huggingface.co/maidalun1020/bce-embedding-base_v1 \
  78. /huggingface.co/maidalun1020/bce-reranker-base_v1 \
  79. | tar -xf - --strip-components=2 -C /root/.ragflow
  80. # Copy nltk data downloaded via download_deps.py
  81. COPY nltk_data /root/nltk_data
  82. # Copy compiled web pages
  83. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  84. # Copy Python environment and packages
  85. ENV VIRTUAL_ENV=/ragflow/.venv
  86. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  87. ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
  88. ENV PYTHONPATH=/ragflow/
  89. COPY docker/entrypoint.sh ./entrypoint.sh
  90. RUN chmod +x ./entrypoint.sh
  91. ENTRYPOINT ["./entrypoint.sh"]