开发者
资源
我要评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

源码构建步骤

获取Dify源码,进行API侧和Web前端源码构建。

  1. 获取Dify源码。
    1
    git clone --branch 1.13.3 --depth 1 https://github.com/langgenius/dify.git 
    
  2. 检查API和Web版本要求(该步骤用于确认API侧不需要构建)。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    cd dify
    python3 - <<'PY'
    import tomllib  
    
    api = tomllib.load(open("api/pyproject.toml", "rb")) 
    print("api_name=" + api["project"]["name"]) 
    print("api_version=" + api["project"]["version"]) 
    print("api_requires_python=" + api["project"]["requires-python"]) 
    print("api_package=" + str(api.get("tool", {}).get("uv", {}).get("package"))) 
    PY
    
    预期包含以下内容:
    1
    2
    3
    4
    api_name=dify-api 
    api_version=1.13.3 
    api_requires_python=>=3.11,<3.13 
    api_package=False
    

    api_package=False表示API侧不需要构建。API的可运行内容是“api/”源码目录、已安装的Python依赖和运行时配置。

  3. Web前端源码构建。
    1
    2
    3
    cd web 
    pnpm install --frozen-lockfile 
    pnpm build
    
    该步骤会从源码生成Next.js构建产物,构建产物示例如下,构建产物说明如表1所示。
    1
    2
    3
    4
    .next/BUILD_ID 
    .next/routes-manifest.json 
    .next/required-server-files.json 
    public/manifest.json
    
    表1 Web构建产物说明

    产物

    说明

    .next/BUILD_ID

    当前Web构建的唯一标识。

    .next/routes-manifest.json

    Next.js路由构建结果。

    .next/required-server-files.json

    Web服务启动所需文件清单。

    public/manifest.json

    前端静态资源清单。