Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 646ac1f

Browse files
authored
Improved image build instructions (infiniflow#3580)
### What problem does this PR solve? Improved arm64 image build instructions ### Type of change - [x] Documentation Update - [x] Refactoring
1 parent 8872aed commit 646ac1f

12 files changed

Lines changed: 110 additions & 88 deletions

File tree

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ jobs:
4848
- name: Build ragflow:dev-slim
4949
run: |
5050
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
51-
cp -r ${RUNNER_WORKSPACE_PREFIX}/huggingface.co ${RUNNER_WORKSPACE_PREFIX}/nltk_data ${RUNNER_WORKSPACE_PREFIX}/libssl*.deb ${RUNNER_WORKSPACE_PREFIX}/tika-server*.jar* .
52-
sudo docker pull ubuntu:24.04
53-
sudo ./build_docker_image.sh slim
51+
cp -r ${RUNNER_WORKSPACE_PREFIX}/huggingface.co ${RUNNER_WORKSPACE_PREFIX}/nltk_data ${RUNNER_WORKSPACE_PREFIX}/libssl*.deb ${RUNNER_WORKSPACE_PREFIX}/tika-server*.jar* ${RUNNER_WORKSPACE_PREFIX}/chrome* ${RUNNER_WORKSPACE_PREFIX}/cl100k_base.tiktoken .
52+
sudo docker pull ubuntu:22.04
53+
sudo docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
5454
5555
- name: Build ragflow:dev
5656
run: |
57-
sudo ./build_docker_image.sh full
57+
sudo docker build -f Dockerfile -t infiniflow/ragflow:dev .
5858
5959
- name: Start ragflow:dev-slim
6060
run: |

Dockerfile

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# base stage
22
FROM ubuntu:22.04 AS base
33
USER root
4+
SHELL ["/bin/bash", "-c"]
45

5-
ARG ARCH=amd64
66
ENV LIGHTEN=0
77

88
WORKDIR /ragflow
@@ -18,7 +18,7 @@ RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g'
1818

1919
RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
2020
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 \
21-
libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget \
21+
libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget git \
2222
&& rm -rf /var/lib/apt/lists/*
2323

2424
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" \
@@ -28,8 +28,11 @@ RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple &&
2828
# https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
2929
# aspose-slides on linux/arm64 is unavailable
3030
RUN --mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_amd64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
31-
if [ "${ARCH}" = "amd64" ]; then \
31+
--mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_arm64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_arm64.deb \
32+
if [ "$(uname -m)" = "x86_64" ]; then \
3233
dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
34+
elif [ "$(uname -m)" = "aarch64" ]; then \
35+
dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
3336
fi
3437

3538
ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
@@ -56,6 +59,24 @@ USER root
5659

5760
WORKDIR /ragflow
5861

62+
COPY .git /ragflow/.git
63+
64+
RUN current_commit=$(git rev-parse --short HEAD); \
65+
last_tag=$(git describe --tags --abbrev=0); \
66+
commit_count=$(git rev-list --count "$last_tag..HEAD"); \
67+
version_info=""; \
68+
if [ "$commit_count" -eq 0 ]; then \
69+
version_info=$last_tag; \
70+
else \
71+
version_info="$current_commit($last_tag~$commit_count)"; \
72+
fi; \
73+
if [ "$LIGHTEN" == "1" ]; then \
74+
version_info="$version_info slim"; \
75+
else \
76+
version_info="$version_info full"; \
77+
fi; \
78+
echo $version_info > /ragflow/VERSION
79+
5980
COPY web web
6081
COPY docs docs
6182
RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
@@ -65,10 +86,10 @@ RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
6586
COPY pyproject.toml poetry.toml poetry.lock ./
6687

6788
RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
68-
if [ "$LIGHTEN" -eq 0 ]; then \
69-
poetry install --no-root --with=full; \
70-
else \
89+
if [ "$LIGHTEN" == "1" ]; then \
7190
poetry install --no-root; \
91+
else \
92+
poetry install --no-root --with=full; \
7293
fi
7394

7495
# production stage
@@ -77,6 +98,8 @@ USER root
7798

7899
WORKDIR /ragflow
79100

101+
COPY --from=builder /ragflow/VERSION /ragflow/VERSION
102+
80103
# Install python packages' dependencies
81104
# cv2 requires libGL.so.1
82105
RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=locked \

Dockerfile.slim

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# base stage
22
FROM ubuntu:22.04 AS base
33
USER root
4+
SHELL ["/bin/bash", "-c"]
45

5-
ARG ARCH=amd64
66
ENV LIGHTEN=1
77

88
WORKDIR /ragflow
@@ -18,7 +18,7 @@ RUN sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g'
1818

1919
RUN --mount=type=cache,id=ragflow_base_apt,target=/var/cache/apt,sharing=locked \
2020
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 \
21-
libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget \
21+
libatk-bridge2.0-0 libgtk-4-1 libnss3 xdg-utils unzip libgbm-dev wget git \
2222
&& rm -rf /var/lib/apt/lists/*
2323

2424
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" \
@@ -28,8 +28,11 @@ RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple &&
2828
# https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13
2929
# aspose-slides on linux/arm64 is unavailable
3030
RUN --mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_amd64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
31-
if [ "${ARCH}" = "amd64" ]; then \
31+
--mount=type=bind,source=libssl1.1_1.1.1f-1ubuntu2_arm64.deb,target=/root/libssl1.1_1.1.1f-1ubuntu2_arm64.deb \
32+
if [ "$(uname -m)" = "x86_64" ]; then \
3233
dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \
34+
elif [ "$(uname -m)" = "aarch64" ]; then \
35+
dpkg -i /root/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \
3336
fi
3437

3538
ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
@@ -56,6 +59,24 @@ USER root
5659

5760
WORKDIR /ragflow
5861

62+
COPY .git /ragflow/.git
63+
64+
RUN current_commit=$(git rev-parse --short HEAD); \
65+
last_tag=$(git describe --tags --abbrev=0); \
66+
commit_count=$(git rev-list --count "$last_tag..HEAD"); \
67+
version_info=""; \
68+
if [ "$commit_count" -eq 0 ]; then \
69+
version_info=$last_tag; \
70+
else \
71+
version_info="$current_commit($last_tag~$commit_count)"; \
72+
fi; \
73+
if [ "$LIGHTEN" == "1" ]; then \
74+
version_info="$version_info slim"; \
75+
else \
76+
version_info="$version_info full"; \
77+
fi; \
78+
echo $version_info > /ragflow/VERSION
79+
5980
COPY web web
6081
COPY docs docs
6182
RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
@@ -65,10 +86,10 @@ RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
6586
COPY pyproject.toml poetry.toml poetry.lock ./
6687
6788
RUN --mount=type=cache,id=ragflow_builder_poetry,target=/root/.cache/pypoetry,sharing=locked \
68-
if [ "$LIGHTEN" -eq 0 ]; then \
69-
poetry install --no-root --with=full; \
70-
else \
89+
if [ "$LIGHTEN" == "1" ]; then \
7190
poetry install --no-root; \
91+
else \
92+
poetry install --no-root --with=full; \
7293
fi
7394

7495
# production stage
@@ -77,6 +98,8 @@ USER root
7798

7899
WORKDIR /ragflow
79100

101+
COPY --from=builder /ragflow/VERSION /ragflow/VERSION
102+
80103
# Install python packages' dependencies
81104
# cv2 requires libGL.so.1
82105
RUN --mount=type=cache,id=ragflow_production_apt,target=/var/cache/apt,sharing=locked \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ git clone https://github.com/infiniflow/ragflow.git
274274
cd ragflow/
275275
pip3 install huggingface-hub nltk
276276
python3 download_deps.py
277-
bash build_docker_image.sh slim
277+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
278278
```
279279
280280
## 🔧 Build a Docker image including embedding models
@@ -286,7 +286,7 @@ git clone https://github.com/infiniflow/ragflow.git
286286
cd ragflow/
287287
pip3 install huggingface-hub nltk
288288
python3 download_deps.py
289-
bash build_docker_image.sh full
289+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
290290
```
291291
292292
## 🔨 Launch service from source for development

README_id.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ git clone https://github.com/infiniflow/ragflow.git
249249
cd ragflow/
250250
pip3 install huggingface-hub nltk
251251
python3 download_deps.py
252-
bash build_docker_image.sh slim
252+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
253253
```
254254
255255
## 🔧 Membangun Docker Image Termasuk Model Embedding
@@ -261,7 +261,7 @@ git clone https://github.com/infiniflow/ragflow.git
261261
cd ragflow/
262262
pip3 install huggingface-hub nltk
263263
python3 download_deps.py
264-
bash build_docker_image.sh full
264+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
265265
```
266266

267267
## 🔨 Menjalankan Aplikasi dari untuk Pengembangan

README_ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ git clone https://github.com/infiniflow/ragflow.git
230230
cd ragflow/
231231
pip3 install huggingface-hub nltk
232232
python3 download_deps.py
233-
bash build_docker_image.sh slim
233+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
234234
```
235235

236236
## 🔧 ソースコードをコンパイルしたDockerイメージ(埋め込みモデルを含む)
@@ -242,7 +242,7 @@ git clone https://github.com/infiniflow/ragflow.git
242242
cd ragflow/
243243
pip3 install huggingface-hub nltk
244244
python3 download_deps.py
245-
bash build_docker_image.sh full
245+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
246246
```
247247

248248
## 🔨 ソースコードからサービスを起動する方法

README_ko.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ git clone https://github.com/infiniflow/ragflow.git
232232
cd ragflow/
233233
pip3 install huggingface-hub nltk
234234
python3 download_deps.py
235-
bash build_docker_image.sh slim
235+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
236236
```
237237

238238
## 🔧 소스 코드로 Docker 이미지를 컴파일합니다(임베딩 모델 포함)
@@ -244,7 +244,7 @@ git clone https://github.com/infiniflow/ragflow.git
244244
cd ragflow/
245245
pip3 install huggingface-hub nltk
246246
python3 download_deps.py
247-
bash build_docker_image.sh full
247+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
248248
```
249249

250250
## 🔨 소스 코드로 서비스를 시작합니다.

README_zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ git clone https://github.com/infiniflow/ragflow.git
237237
cd ragflow/
238238
pip3 install huggingface-hub nltk
239239
python3 download_deps.py
240-
bash build_docker_image.sh slim
240+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
241241
```
242242

243243
## 🔧 源码编译 Docker 镜像(包含 embedding 模型)
@@ -249,7 +249,7 @@ git clone https://github.com/infiniflow/ragflow.git
249249
cd ragflow/
250250
pip3 install huggingface-hub nltk
251251
python3 download_deps.py
252-
bash build_docker_image.sh full
252+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
253253
```
254254

255255
## 🔨 以源代码启动服务

api/versions.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,51 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
17+
import os
1618
import subprocess
1719

18-
def get_ragflow_version() -> str:
19-
return RAGFLOW_VERSION_INFO
20+
RAGFLOW_VERSION_INFO = "unknown"
2021

2122

22-
RAGFLOW_VERSION_INFO = "dev"
23+
def get_ragflow_version() -> str:
24+
global RAGFLOW_VERSION_INFO
25+
if RAGFLOW_VERSION_INFO != "unknown":
26+
return RAGFLOW_VERSION_INFO
27+
version_path = os.path.abspath(
28+
os.path.join(
29+
os.path.dirname(os.path.realpath(__file__)), os.pardir, "VERSION"
30+
)
31+
)
32+
if os.path.exists(version_path):
33+
with open(version_path, "r") as f:
34+
RAGFLOW_VERSION_INFO = f.read().strip()
35+
else:
36+
RAGFLOW_VERSION_INFO = get_closest_tag_and_count()
37+
LIGHTEN = int(os.environ.get("LIGHTEN", "0"))
38+
RAGFLOW_VERSION_INFO += " slim" if LIGHTEN == 1 else " full"
39+
return RAGFLOW_VERSION_INFO
2340

2441

2542
def get_closest_tag_and_count():
2643
try:
2744
# Get the current commit hash
28-
commit_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')
45+
commit_id = (
46+
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
47+
.strip()
48+
.decode("utf-8")
49+
)
2950
# Get the closest tag
30-
closest_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')
31-
# Get the commit hash of the closest tag
32-
closest_tag_commit = subprocess.check_output(['git', 'rev-list', '-n', '1', closest_tag]).strip().decode(
33-
'utf-8')
51+
closest_tag = (
52+
subprocess.check_output(["git", "describe", "--tags", "--abbrev=0"])
53+
.strip()
54+
.decode("utf-8")
55+
)
3456
# Get the commit count since the closest tag
35-
process = subprocess.Popen(['git', 'rev-list', '--count', f'{closest_tag}..HEAD'], stdout=subprocess.PIPE)
57+
process = subprocess.Popen(
58+
["git", "rev-list", "--count", f"{closest_tag}..HEAD"],
59+
stdout=subprocess.PIPE,
60+
)
3661
commits_count, _ = process.communicate()
3762
commits_count = int(commits_count.strip())
3863

@@ -41,8 +66,4 @@ def get_closest_tag_and_count():
4166
else:
4267
return f"{commit_id}({closest_tag}~{commits_count})"
4368
except Exception:
44-
return 'unknown'
45-
46-
47-
if RAGFLOW_VERSION_INFO == 'dev':
48-
RAGFLOW_VERSION_INFO = get_closest_tag_and_count()
69+
return "unknown"

build_docker_image.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)