说明
在「Mac 上编译 Ragflow」的文章中只是简单的说到可以通过 Remote Development 来进入容器,可以通过修改Dockerfile的方式,增加映射卷的方式来开发。为什么要映射卷呢?这样可以保持 ragflow 原有的目录结构,同时保持 git 的代码管理,文件在卷中也不用担心因容器销毁等导致修改代码丢失的情况。
我今天完整的走通了开发的过程,重新整理开发部分的文档。为了保持完整,保留了 Remote Development 的部分说明。注意,前提是已经在 Mac 上编译完 ragflow 的 Dockerfile,并且可以正常运行。
开发
Remote Development
VS Code 安装 Remote Development 插件。它包含多个插件,其中 Dev Containters 可以连接到 Docker 容器作为开发环境,这样的好处是开发环境与部署环境一致。

当安装好 Remote Development,就可以通过 Remote Explorer 查看已经安装的容器,并通过点击对应容器的箭头(注意下图红色框的部分)。

进入到容器内部,选对应的目录,就可以打开 /ragflow,这样就能看到实际的代码了。

修改Dockerfile
主要是屏蔽编译过程和 probuction 步骤,增加 /raflow 卷的映射。
# base stage
FROM docker.m.daocloud.io/ubuntu:22.04 AS base
USER root
SHELL ["/bin/bash", "-c"]
ARG NEED_MIRROR=0
ARG LIGHTEN=0
ENV LIGHTEN=${LIGHTEN}
WORKDIR /ragflow
# Copy models downloaded via download_deps.py
RUN mkdir -p /ragflow/rag/res/deepdoc /root/.ragflow
RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
cp /huggingface.co/InfiniFlow/huqie/huqie.txt.trie /ragflow/rag/res/ && \
tar --exclude='.*' -cf - \
/huggingface.co/InfiniFlow/text_concat_xgb_v1.0 \
/huggingface.co/InfiniFlow/deepdoc \
| tar -xf - --strip-components=3 -C /ragflow/rag/res/deepdoc
RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/huggingface.co,target=/huggingface.co \
if [ "$LIGHTEN" != "1" ]; then \
(tar -cf - \
/huggingface.co/BAAI/bge-large-zh-v1.5 \
/huggingface.co/BAAI/bge-reranker-v2-m3 \
/huggingface.co/maidalun1020/bce-embedding-base_v1 \
/huggingface.co/maidalun1020/bce-reranker-base_v1 \
| tar -xf - --strip-components=2 -C /root/.ragflow) \
fi
# https://github.com/chrismattmann/tika-python
# 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.
RUN --mount=type=bind,from=infiniflow/ragflow_deps:latest,source=/,target=/deps \
cp -r /deps/nltk_data /root/ && \
cp /deps/tika-server-standard-3.0.0.jar /deps/tika-server-standard-3.0.0.jar.md5 /ragflow/ && \
cp /deps/cl100k_base.tiktoken /ragflow/9b5ad71b2ce5302211f9c61530b329a4922fc6a4
ENV TIKA_SERVER_JAR="file:///ragflow/tika-server-standard-3.0.0.jar"
ENV DEBIAN_FRONTEND=noninteractive
# Setup apt
# Python package and implicit dependencies:
# opencv-python: libglib2.0-0 libglx-mesa0 libgl1
# aspose-slides: pkg-config libicu-dev libgdiplus libssl1.1_1.1.1f-1ubuntu2_amd64.deb
# python-pptx: default-jdk tika-server-standard-3.0.0.jar
# selenium: libatk-bridge2.0-0 chrome-linux64-121-0-6167-85
# Building C extensions: libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev
RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
if [ "$NEED_MIRRO

最低0.47元/天 解锁文章
1132

被折叠的 条评论
为什么被折叠?



