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.slim 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # base stage
  2. FROM ubuntu:24.04 AS base
  3. USER root
  4. ARG ARCH=amd64
  5. ENV LIGHTEN=1
  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. RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
  14. apt update && apt install -y curl libpython3-dev nginx libglib2.0-0 libglx-mesa0 pkg-config libicu-dev libgdiplus default-jdk python3-pip pipx \
  15. && rm -rf /var/lib/apt/lists/*
  16. RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && pip3 config set global.trusted-host "pypi.tuna.tsinghua.edu.cn mirrors.pku.edu.cn" && pip3 config set global.extra-index-url "https://mirrors.pku.edu.cn/pypi/web/simple" \
  17. && pipx install poetry \
  18. && /root/.local/bin/poetry self add poetry-plugin-pypi-mirror
  19. # https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
  20. # aspose-slides on linux/arm64 is unavailable
  21. RUN --mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_amd64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
  22. if [ "${ARCH}" = "amd64" ]; then \
  23. dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
  24. fi
  25. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  26. ENV PATH=/root/.local/bin:$PATH
  27. # Configure Poetry
  28. ENV POETRY_NO_INTERACTION=1
  29. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  30. ENV POETRY_VIRTUALENVS_CREATE=true
  31. ENV POETRY_REQUESTS_TIMEOUT=15
  32. ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
  33. # builder stage
  34. FROM base AS builder
  35. USER root
  36. WORKDIR /ragflow
  37. RUN --mount=type=cache,id=ragflow_builder_apt,target=/var/cache/apt,sharing=locked \
  38. apt update && apt install -y nodejs npm cargo && \
  39. rm -rf /var/lib/apt/lists/*
  40. COPY web web
  41. COPY docs docs
  42. RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
  43. cd web && npm i && npm run build
  44. # install dependencies from poetry.lock file
  45. COPY pyproject.toml poetry.toml poetry.lock ./
  46. RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
  47. if [ "$LIGHTEN" -eq 0 ]; then \
  48. poetry install --no-root --with=full; \
  49. else \
  50. poetry install --no-root; \
  51. fi
  52. # production stage
  53. FROM base AS production
  54. USER root
  55. WORKDIR /ragflow
  56. # Install python packages' dependencies
  57. # cv2 requires libGL.so.1
  58. RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=locked \
  59. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  60. rm -rf /var/lib/apt/lists/*
  61. COPY web web
  62. COPY api api
  63. COPY conf conf
  64. COPY deepdoc deepdoc
  65. COPY rag rag
  66. COPY agent agent
  67. COPY graphrag graphrag
  68. COPY pyproject.toml poetry.toml poetry.lock ./
  69. # Copy models downloaded via download_deps.py
  70. RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
  71. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  72. tar --exclude='.*' -cf - \
  73. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  74. /huggingface.co/InfiniFlow/deepdoc \
  75. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  76. # Copy nltk data downloaded via download_deps.py
  77. COPY nltk_data /root/nltk_data
  78. # https://github.com/chrismattmann/tika-python
  79. # 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.
  80. COPY tika-server-standard-3.0.0.jar tika-server-standard-3.0.0.jar.md5 ./
  81. ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard.jar"
  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"]