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 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # base stage
  2. FROM ubuntu:22.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. # Setup apt mirror site
  12. RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
  13. RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
  14. apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl libpython3-dev nginx libglib2.0-0 libglx-mesa0 pkg-config libicu-dev libgdiplus default-jdk python3-pip pipx \
  15. libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget \
  16. && rm -rf /var/lib/apt/lists/*
  17. 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" \
  18. && pipx install poetry \
  19. && /root/.local/bin/poetry self add poetry-plugin-pypi-mirror
  20. # https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
  21. # aspose-slides on linux/arm64 is unavailable
  22. RUN --mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_amd64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
  23. if [ "${ARCH}" = "amd64" ]; then \
  24. dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
  25. fi
  26. ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
  27. ENV PATH=/root/.local/bin:$PATH
  28. # Configure Poetry
  29. ENV POETRY_NO_INTERACTION=1
  30. ENV POETRY_VIRTUALENVS_IN_PROJECT=true
  31. ENV POETRY_VIRTUALENVS_CREATE=true
  32. ENV POETRY_REQUESTS_TIMEOUT=15
  33. ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
  34. # nodejs 12.22 on Ubuntu 22.04 is too old
  35. RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
  36. curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
  37. apt purge -y nodejs npm && \
  38. apt autoremove && \
  39. apt update && \
  40. apt install -y nodejs cargo && \
  41. rm -rf /var/lib/apt/lists/*
  42. # builder stage
  43. FROM base AS builder
  44. USER root
  45. WORKDIR /ragflow
  46. COPY web web
  47. COPY docs docs
  48. RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
  49. cd web && npm install --force && npm run build
  50. # install dependencies from poetry.lock file
  51. COPY pyproject.toml poetry.toml poetry.lock ./
  52. RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
  53. if [ "$LIGHTEN" -eq 0 ]; then \
  54. poetry install --no-root --with=full; \
  55. else \
  56. poetry install --no-root; \
  57. fi
  58. # production stage
  59. FROM base AS production
  60. USER root
  61. WORKDIR /ragflow
  62. # Install python packages' dependencies
  63. # cv2 requires libGL.so.1
  64. RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=locked \
  65. apt update && apt install -y --no-install-recommends nginx libgl1 vim less && \
  66. rm -rf /var/lib/apt/lists/*
  67. COPY web web
  68. COPY api api
  69. COPY conf conf
  70. COPY deepdoc deepdoc
  71. COPY rag rag
  72. COPY agent agent
  73. COPY graphrag graphrag
  74. COPY pyproject.toml poetry.toml poetry.lock ./
  75. # Copy models downloaded via download_deps.py
  76. RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
  77. RUN --mount=type=bind,source=huggingface.co,target=/huggingface.co \
  78. tar --exclude='.*' -cf - \
  79. /huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
  80. /huggingface.co/InfiniFlow/deepdoc \
  81. | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
  82. # Copy nltk data downloaded via download_deps.py
  83. COPY nltk_data /root/nltk_data
  84. # https://github.com/chrismattmann/tika-python
  85. # 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.
  86. COPY tika-server-standard-3.0.0.jar /ragflow/tika-server-standard.jar
  87. COPY tika-server-standard-3.0.0.jar.md5 /ragflow/tika-server-standard.jar.md5
  88. ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard.jar"
  89. # Copy cl100k_base
  90. COPY cl100k_base.tiktoken /ragflow/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
  91. # Add dependencies of selenium
  92. RUN --mount=type=bind,source=chrome-linux64-121-0-6167-85,target=/chrome-linux64.zip \
  93. unzip /chrome-linux64.zip && \
  94. mv chrome-linux64 /opt/chrome/ && \
  95. ln -s /opt/chrome/chrome /usr/local/bin/
  96. RUN --mount=type=bind,source=chromedriver-linux64-121-0-6167-85,target=/chromedriver-linux64.zip \
  97. unzip -j /chromedriver-linux64.zip chromedriver-linux64/chromedriver && \
  98. mv chromedriver /usr/local/bin/ && \
  99. rm -f /usr/bin/google-chrome
  100. # Copy compiled web pages
  101. COPY --from=builder /ragflow/web/dist /ragflow/web/dist
  102. # Copy Python environment and packages
  103. ENV VIRTUAL_ENV=/ragflow/.venv
  104. COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
  105. ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
  106. ENV PYTHONPATH=/ragflow/
  107. COPY docker/service_conf.yaml.template ./conf/service_conf.yaml.template
  108. COPY docker/entrypoint.sh ./entrypoint.sh
  109. RUN chmod +x ./entrypoint.sh
  110. ENTRYPOINT ["./entrypoint.sh"]