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.5KB

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 && \
  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 lock
  34. RUN --mount=type=cache,target=/root/.cache/pypoetry,sharing=locked \
  35. /root/.local/bin/poetry install --sync --no-cache --no-root
  36. # production stage
  37. FROM base AS production
  38. USER root
  39. WORKDIR /ragflow
  40. # Install python packages' dependencies
  41. # cv2 requires libGL.so.1
  42. RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  43. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  44. rm -rf /var/lib/apt/lists/*
  45. COPY web web
  46. COPY api api
  47. COPY conf conf
  48. COPY deepdoc deepdoc
  49. COPY rag rag
  50. COPY agent agent
  51. COPY graphrag graphrag
  52. COPY pyproject.toml poetry.toml poetry.lock ./
  53. # Copy compiled web pages
  54. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  55. # Copy Python environment and packages
  56. ENV VIRTUAL_ENV=/ragflow/.venv
  57. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  58. ENV PATH="${VIRTUAL_ENV}/bin:/root/.local/bin:${PATH}"
  59. # Download nltk data
  60. RUN python3 -m nltk.downloader wordnet punkt punkt_tab
  61. ENV PYTHONPATH=/ragflow/
  62. COPY docker/entrypoint.sh ./entrypoint.sh
  63. RUN chmod +x ./entrypoint.sh
  64. ENTRYPOINT ["./entrypoint.sh"]