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.scratch 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # base stage
  2. FROM ubuntu:24.04 AS base
  3. USER root
  4. WORKDIR /ragflow
  5. RUN rm -f /etc/apt/apt.conf.d/docker-clean \
  6. && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
  7. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  8. apt update && apt-get --no-install-recommends install -y ca-certificates
  9. # if you located in China, you can use tsinghua mirror to speed up apt
  10. RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources
  11. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  12. apt update && apt install -y curl libpython3-dev nginx libglib2.0-0 libglx-mesa0 \
  13. && rm -rf /var/lib/apt/lists/* \
  14. && curl -sSL https://install.python-poetry.org | python3 -
  15. ENV PYTHONDONTWRITEBYTECODE=1 LD_LIBRARY_PATH=usr/lib/x86_64-linux-gnu/openmpi/lib:$LD_LIBRARY_PATH
  16. # Configure Poetry
  17. ENV POETRY_NO_INTERACTION=1
  18. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  19. ENV POETRY_VIRTUALENVS_CREATE=true
  20. ENV POETRY_REQUESTS_TIMEOUT=15
  21. # builder stage
  22. FROM base AS builder
  23. USER root
  24. WORKDIR /ragflow
  25. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  26. apt update && apt install -y nodejs npm cargo && \
  27. rm -rf /var/lib/apt/lists/*
  28. COPY web web
  29. RUN cd web && npm i --force && npm run build
  30. # install dependencies from poetry.lock file
  31. COPY pyproject.toml poetry.toml poetry.lock ./
  32. RUN --mount=type=cache,target=/root/.cache/pypoetry,sharing=locked \
  33. /root/.local/bin/poetry install --sync --no-cache --no-root
  34. # production stage
  35. FROM base AS production
  36. USER root
  37. WORKDIR /ragflow
  38. # Install python packages' dependencies
  39. # cv2 requires libGL.so.1
  40. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  41. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  42. rm -rf /var/lib/apt/lists/*
  43. COPY web web
  44. COPY api api
  45. COPY conf conf
  46. COPY deepdoc deepdoc
  47. COPY rag rag
  48. COPY agent agent
  49. COPY graphrag graphrag
  50. COPY pyproject.toml poetry.toml poetry.lock ./
  51. # Copy compiled web pages
  52. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  53. # Copy Python environment and packages
  54. ENV VIRTUAL_ENV=/ragflow/.venv
  55. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  56. ENV PATH="${VIRTUAL_ENV}/bin:/root/.local/bin:${PATH}"
  57. # Download nltk data
  58. RUN python3 -m nltk.downloader wordnet punkt punkt_tab
  59. # Copy models downloaded via download_deps.sh
  60. # COPY det.onnx layout.laws.onnx layout.manual.onnx layout.onnx layout.paper.onnx ocr.res rec.onnx tsr.onnx updown_concat_xgb.model /ragflow/rag/res/deepdoc/
  61. ENV PYTHONPATH=/ragflow/
  62. COPY docker/entrypoint.sh ./entrypoint.sh
  63. RUN chmod +x ./entrypoint.sh
  64. ENTRYPOINT ["./entrypoint.sh"]