zhichyu commited on
Commit
48b04f6
·
1 Parent(s): 6d13ea7

Introduced NEED_MIRROR (#3907)

Browse files

### What problem does this PR solve?

Introduced NEED_MIRROR

### Type of change

- [x] Refactoring

.github/workflows/tests.yml CHANGED
@@ -53,11 +53,11 @@ jobs:
53
  run: |
54
  RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
55
  sudo docker pull ubuntu:22.04
56
- sudo docker build --progress=plain --build-arg LIGHTEN=1 -f Dockerfile -t infiniflow/ragflow:dev-slim .
57
 
58
  - name: Build ragflow:dev
59
  run: |
60
- sudo docker build --progress=plain -f Dockerfile -t infiniflow/ragflow:dev .
61
 
62
  - name: Start ragflow:dev-slim
63
  run: |
 
53
  run: |
54
  RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
55
  sudo docker pull ubuntu:22.04
56
+ sudo docker build --progress=plain --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:dev-slim .
57
 
58
  - name: Build ragflow:dev
59
  run: |
60
+ sudo docker build --progress=plain --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:dev .
61
 
62
  - name: Start ragflow:dev-slim
63
  run: |
Dockerfile CHANGED
@@ -3,6 +3,7 @@ FROM ubuntu:22.04 AS base
3
  USER root
4
  SHELL ["/bin/bash", "-c"]
5
 
 
6
  ARG LIGHTEN=0
7
  ENV LIGHTEN=${LIGHTEN}
8
 
@@ -16,7 +17,7 @@ RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co
16
  /huggingface.co/InfiniFlow/deepdoc \
17
  | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
18
  RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
19
- if [ "$LIGHTEN" == "0" ]; then \
20
  (tar -cf - \
21
  /huggingface.co/BAAI/bge-large-zh-v1.5 \
22
  /huggingface.co/BAAI/bge-reranker-v2-m3 \
@@ -35,25 +36,27 @@ RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps
35
  ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard-3.0.0.jar"
36
 
37
  # Setup apt
 
38
  RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
39
- sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list && \
 
 
40
  rm -f /etc/apt/apt.conf.d/docker-clean && \
41
  echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \
42
- apt update && apt --no-install-recommends install -y ca-certificates && \
43
- rm -rf /var/lib/apt/lists/*
44
-
45
- # cv2 requires libGL.so.1
46
- RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
47
- 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 \
48
- libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget git nginx libgl1 vim less && \
49
- rm -rf /var/lib/apt/lists/*
50
 
51
- RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
52
- pip3 config set global.trusted-host pypi.tuna.tsinghua.edu.cn && \
53
- pipx install poetry && \
54
- pipx runpip poetry config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
55
- pipx runpip poetry config set global.trusted-host pypi.tuna.tsinghua.edu.cn && \
56
- /root/.local/bin/poetry self add poetry-plugin-pypi-mirror
 
 
57
 
58
  ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
59
  ENV PATH=/root/.local/bin:$PATH
@@ -62,7 +65,6 @@ ENV POETRY_NO_INTERACTION=1
62
  ENV POETRY_VIRTUALENVS_IN_PROJECT=true
63
  ENV POETRY_VIRTUALENVS_CREATE=true
64
  ENV POETRY_REQUESTS_TIMEOUT=15
65
- ENV POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
66
 
67
  # nodejs 12.22 on Ubuntu 22.04 is too old
68
  RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
@@ -70,8 +72,7 @@ RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
70
  apt purge -y nodejs npm && \
71
  apt autoremove && \
72
  apt update && \
73
- apt install -y nodejs cargo && \
74
- rm -rf /var/lib/apt/lists/*
75
 
76
  # Add dependencies of selenium
77
  RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chrome-linux64-121-0-6167-85,target=/chrome-linux64.zip \
@@ -103,6 +104,9 @@ WORKDIR /ragflow
103
  COPY pyproject.toml poetry.toml poetry.lock ./
104
 
105
  RUN --mount=type=cache,id=ragflow_poetry,target=/root/.cache/pypoetry,sharing=locked \
 
 
 
106
  if [ "$LIGHTEN" == "1" ]; then \
107
  poetry install --no-root; \
108
  else \
 
3
  USER root
4
  SHELL ["/bin/bash", "-c"]
5
 
6
+ ARG NEED_MIRROR=0
7
  ARG LIGHTEN=0
8
  ENV LIGHTEN=${LIGHTEN}
9
 
 
17
  /huggingface.co/InfiniFlow/deepdoc \
18
  | tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
19
  RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
20
+ if [ "$LIGHTEN" != "1" ]; then \
21
  (tar -cf - \
22
  /huggingface.co/BAAI/bge-large-zh-v1.5 \
23
  /huggingface.co/BAAI/bge-reranker-v2-m3 \
 
36
  ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard-3.0.0.jar"
37
 
38
  # Setup apt
39
+ # cv2 requires libGL.so.1
40
  RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
41
+ if [ "$NEED_MIRROR" == "1" ]; then \
42
+ sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list; \
43
+ fi; \
44
  rm -f /etc/apt/apt.conf.d/docker-clean && \
45
  echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \
46
+ apt update && \
47
+ apt --no-install-recommends install -y ca-certificates && \
48
+ apt update && \
49
+ 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 \
50
+ libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget git nginx libgl1 vim less
 
 
 
51
 
52
+ RUN if [ "$NEED_MIRROR" == "1" ]; then \
53
+ pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
54
+ pip3 config set global.trusted-host pypi.tuna.tsinghua.edu.cn; \
55
+ fi; \
56
+ pipx install poetry; \
57
+ if [ "$NEED_MIRROR" == "1" ]; then \
58
+ pipx inject poetry poetry-plugin-pypi-mirror; \
59
+ fi
60
 
61
  ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
62
  ENV PATH=/root/.local/bin:$PATH
 
65
  ENV POETRY_VIRTUALENVS_IN_PROJECT=true
66
  ENV POETRY_VIRTUALENVS_CREATE=true
67
  ENV POETRY_REQUESTS_TIMEOUT=15
 
68
 
69
  # nodejs 12.22 on Ubuntu 22.04 is too old
70
  RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
 
72
  apt purge -y nodejs npm && \
73
  apt autoremove && \
74
  apt update && \
75
+ apt install -y nodejs cargo
 
76
 
77
  # Add dependencies of selenium
78
  RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/chrome-linux64-121-0-6167-85,target=/chrome-linux64.zip \
 
104
  COPY pyproject.toml poetry.toml poetry.lock ./
105
 
106
  RUN --mount=type=cache,id=ragflow_poetry,target=/root/.cache/pypoetry,sharing=locked \
107
+ if [ "$NEED_MIRROR" == "1" ]; then \
108
+ export POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/; \
109
+ fi; \
110
  if [ "$LIGHTEN" == "1" ]; then \
111
  poetry install --no-root; \
112
  else \
README.md CHANGED
@@ -289,14 +289,14 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
289
 
290
  1. Install Poetry, or skip this step if it is already installed:
291
  ```bash
292
- curl -sSL https://install.python-poetry.org | python3 -
 
293
  ```
294
 
295
  2. Clone the source code and install Python dependencies:
296
  ```bash
297
  git clone https://github.com/infiniflow/ragflow.git
298
  cd ragflow/
299
- export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
300
  ~/.local/bin/poetry install --sync --no-root --with=full # install RAGFlow dependent python modules
301
  ```
302
 
 
289
 
290
  1. Install Poetry, or skip this step if it is already installed:
291
  ```bash
292
+ pipx install poetry
293
+ export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
294
  ```
295
 
296
  2. Clone the source code and install Python dependencies:
297
  ```bash
298
  git clone https://github.com/infiniflow/ragflow.git
299
  cd ragflow/
 
300
  ~/.local/bin/poetry install --sync --no-root --with=full # install RAGFlow dependent python modules
301
  ```
302
 
README_id.md CHANGED
@@ -264,14 +264,14 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
264
 
265
  1. Instal Poetry, atau lewati langkah ini jika sudah terinstal:
266
  ```bash
267
- curl -sSL https://install.python-poetry.org | python3 -
 
268
  ```
269
 
270
  2. Clone kode sumber dan instal dependensi Python:
271
  ```bash
272
  git clone https://github.com/infiniflow/ragflow.git
273
  cd ragflow/
274
- export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
275
  ~/.local/bin/poetry install --sync --no-root # install modul python RAGFlow
276
  ```
277
 
 
264
 
265
  1. Instal Poetry, atau lewati langkah ini jika sudah terinstal:
266
  ```bash
267
+ pipx install poetry
268
+ export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
269
  ```
270
 
271
  2. Clone kode sumber dan instal dependensi Python:
272
  ```bash
273
  git clone https://github.com/infiniflow/ragflow.git
274
  cd ragflow/
 
275
  ~/.local/bin/poetry install --sync --no-root # install modul python RAGFlow
276
  ```
277
 
README_ja.md CHANGED
@@ -245,14 +245,14 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
245
 
246
  1. Poetry をインストールする。すでにインストールされている場合は、このステップをスキップしてください:
247
  ```bash
248
- curl -sSL https://install.python-poetry.org | python3 -
 
249
  ```
250
 
251
  2. ソースコードをクローンし、Python の依存関係をインストールする:
252
  ```bash
253
  git clone https://github.com/infiniflow/ragflow.git
254
  cd ragflow/
255
- export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
256
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
257
  ```
258
 
 
245
 
246
  1. Poetry をインストールする。すでにインストールされている場合は、このステップをスキップしてください:
247
  ```bash
248
+ pipx install poetry
249
+ export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
250
  ```
251
 
252
  2. ソースコードをクローンし、Python の依存関係をインストールする:
253
  ```bash
254
  git clone https://github.com/infiniflow/ragflow.git
255
  cd ragflow/
 
256
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
257
  ```
258
 
README_ko.md CHANGED
@@ -247,14 +247,14 @@ docker build -f Dockerfile -t infiniflow/ragflow:dev .
247
 
248
  1. Poetry를 설치하거나 이미 설치된 경우 이 단계를 건너뜁니다:
249
  ```bash
250
- curl -sSL https://install.python-poetry.org | python3 -
 
251
  ```
252
 
253
  2. 소스 코드를 클론하고 Python 의존성을 설치합니다:
254
  ```bash
255
  git clone https://github.com/infiniflow/ragflow.git
256
  cd ragflow/
257
- export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
258
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
259
  ```
260
 
 
247
 
248
  1. Poetry를 설치하거나 이미 설치된 경우 이 단계를 건너뜁니다:
249
  ```bash
250
+ pipx install poetry
251
+ export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
252
  ```
253
 
254
  2. 소스 코드를 클론하고 Python 의존성을 설치합니다:
255
  ```bash
256
  git clone https://github.com/infiniflow/ragflow.git
257
  cd ragflow/
 
258
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
259
  ```
260
 
README_zh.md CHANGED
@@ -235,7 +235,7 @@ RAGFlow 默认使用 Elasticsearch 存储文本和向量数据. 如果要切换
235
  ```bash
236
  git clone https://github.com/infiniflow/ragflow.git
237
  cd ragflow/
238
- docker build --build-arg LIGHTEN=1 -f Dockerfile -t infiniflow/ragflow:dev-slim .
239
  ```
240
 
241
  ## 🔧 源码编译 Docker 镜像(包含 embedding 模型)
@@ -245,21 +245,23 @@ docker build --build-arg LIGHTEN=1 -f Dockerfile -t infiniflow/ragflow:dev-slim
245
  ```bash
246
  git clone https://github.com/infiniflow/ragflow.git
247
  cd ragflow/
248
- docker build -f Dockerfile -t infiniflow/ragflow:dev .
249
  ```
250
 
251
  ## 🔨 以源代码启动服务
252
 
253
  1. 安装 Poetry。如已经安装,可跳过本步骤:
254
  ```bash
255
- curl -sSL https://install.python-poetry.org | python3 -
 
 
 
256
  ```
257
 
258
  2. 下载源代码并安装 Python 依赖:
259
  ```bash
260
  git clone https://github.com/infiniflow/ragflow.git
261
  cd ragflow/
262
- export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
263
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
264
  ```
265
 
 
235
  ```bash
236
  git clone https://github.com/infiniflow/ragflow.git
237
  cd ragflow/
238
+ docker build --build-arg LIGHTEN=1 --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:dev-slim .
239
  ```
240
 
241
  ## 🔧 源码编译 Docker 镜像(包含 embedding 模型)
 
245
  ```bash
246
  git clone https://github.com/infiniflow/ragflow.git
247
  cd ragflow/
248
+ docker build --build-arg NEED_MIRROR=1 -f Dockerfile -t infiniflow/ragflow:dev .
249
  ```
250
 
251
  ## 🔨 以源代码启动服务
252
 
253
  1. 安装 Poetry。如已经安装,可跳过本步骤:
254
  ```bash
255
+ pipx install poetry
256
+ pipx inject poetry poetry-plugin-pypi-mirror
257
+ export POETRY_VIRTUALENVS_CREATE=true POETRY_VIRTUALENVS_IN_PROJECT=true
258
+ export POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple/
259
  ```
260
 
261
  2. 下载源代码并安装 Python 依赖:
262
  ```bash
263
  git clone https://github.com/infiniflow/ragflow.git
264
  cd ragflow/
 
265
  ~/.local/bin/poetry install --sync --no-root # install RAGFlow dependent python modules
266
  ```
267
 
docs/guides/develop/launch_ragflow_from_source.md CHANGED
@@ -38,7 +38,7 @@ cd ragflow/
38
  1. Install Poetry:
39
 
40
  ```bash
41
- curl -sSL https://install.python-poetry.org | python3 -
42
  ```
43
 
44
  2. Configure Poetry:
 
38
  1. Install Poetry:
39
 
40
  ```bash
41
+ pipx install poetry
42
  ```
43
 
44
  2. Configure Poetry: