Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Dockerfile 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # base stage
  2. FROM ubuntu:24.04 AS base
  3. USER root
  4. ENV LIGHTEN=0
  5. WORKDIR /ragflow
  6. RUN rm -f /etc/apt/apt.conf.d/docker-clean \
  7. && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
  8. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  9. apt update && apt-get --no-install-recommends install -y ca-certificates
  10. # if you located in China, you can use tsinghua mirror to speed up apt
  11. RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources
  12. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  13. apt update && apt install -y curl libpython3-dev nginx libglib2.0-0 libglx-mesa0 pkg-config libicu-dev libgdiplus \
  14. && rm -rf /var/lib/apt/lists/* \
  15. && curl -sSL https://install.python-poetry.org | python3 -
  16. RUN curl -o libssl1.deb http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb && dpkg -i libssl1.deb && rm -f libssl1.deb
  17. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  18. # Configure Poetry
  19. ENV POETRY_NO_INTERACTION=1
  20. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  21. ENV POETRY_VIRTUALENVS_CREATE=true
  22. ENV POETRY_REQUESTS_TIMEOUT=15
  23. # builder stage
  24. FROM base AS builder
  25. USER root
  26. WORKDIR /ragflow
  27. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  28. apt update && apt install -y nodejs npm cargo && \
  29. rm -rf /var/lib/apt/lists/*
  30. COPY web web
  31. RUN cd web && npm i --force && npm run build
  32. # install dependencies from poetry.lock file
  33. COPY pyproject.toml poetry.toml poetry.lock ./
  34. RUN --mount=type=cache,target=/root/.cache/pypoetry,sharing=locked \
  35. if [ "$LIGHTEN" -eq 0 ]; then \
  36. /root/.local/bin/poetry install --sync --no-cache --no-root --with=full; \
  37. else \
  38. /root/.local/bin/poetry install --sync --no-cache --no-root; \
  39. fi
  40. # production stage
  41. FROM base AS production
  42. USER root
  43. WORKDIR /ragflow
  44. # Install python packages' dependencies
  45. # cv2 requires libGL.so.1
  46. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  47. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  48. rm -rf /var/lib/apt/lists/*
  49. COPY web web
  50. COPY api api
  51. COPY conf conf
  52. COPY deepdoc deepdoc
  53. COPY rag rag
  54. COPY agent agent
  55. COPY graphrag graphrag
  56. COPY pyproject.toml poetry.toml poetry.lock ./
  57. # Copy models downloaded via download_deps.py
  58. RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
  59. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  60. tar --exclude='.*' -cf - \
  61. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  62. /huggingface.co/InfiniFlow/deepdoc \
  63. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  64. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  65. tar -cf - \
  66. /huggingface.co/BAAI/bge-large-zh-v1.5 \
  67. /huggingface.co/BAAI/bge-reranker-v2-m3 \
  68. /huggingface.co/maidalun1020/bce-embedding-base_v1 \
  69. /huggingface.co/maidalun1020/bce-reranker-base_v1 \
  70. | tar -xf - --strip-components=2 -C /root/.ragflow
  71. # Copy compiled web pages
  72. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  73. # Copy Python environment and packages
  74. ENV VIRTUAL_ENV=/ragflow/.venv
  75. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  76. ENV PATH="${VIRTUAL_ENV}/bin:/root/.local/bin:${PATH}"
  77. # Download nltk data
  78. RUN python3 -m nltk.downloader wordnet punkt punkt_tab
  79. ENV PYTHONPATH=/ragflow/
  80. COPY docker/entrypoint.sh ./entrypoint.sh
  81. RUN chmod +x ./entrypoint.sh
  82. ENTRYPOINT ["./entrypoint.sh"]