大家好,我是章北海
Dify 是一款开源的大语言模型(LLM) 应用开发平台。它融合了后端即服务(Backend as Service)和 LLMOps 的理念,使开发者可以快速搭建生产级的生成式 AI 应用。即使你是非技术人员,也能参与到 AI 应用的定义和数据运营过程中。
由于 Dify 内置了构建 LLM 应用所需的关键技术栈,包括对数百个模型的支持、直观的 Prompt 编排界面、高质量的 RAG 引擎、稳健的 Agent 框架、灵活的流程编排,并同时提供了一套易用的界面和 API。这为开发者节省了许多重复造轮子的时间,使其可以专注在创新和业务需求上。
1. 开发环境部署
1.1 环境准备
-
Docker Desktop
安装:https://www.docker.com/products/docker-desktop/
-
Git
安装:https://git-scm.com/downloads
-
Node.js(如果需要本地开发前端)
安装:https://nodejs.org/zh-cn/download
1.2 获取代码
git clone https://github.com/langgenius/dify
cd dify
1.3 启动服务
cd docker
docker compose up -d
2. 生产环境离线部署
2.1 在有网络的环境中准备镜像
-
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
langgenius/dify-web 0.14.2 e8a2d31fd02a 6 days ago 431MB
langgenius/dify-api 0.14.2 dc8ef84d4a76 6 days ago 2.95GB
postgres 15-alpine 1ec54b2c6ffc 3 weeks ago 264MB
nginx latest 5e0fa356e6f4 4 weeks ago 197MB
langgenius/dify-sandbox 0.2.10 e09eb1619e46 2 months ago 626MB
redis 6-alpine cdabd876a000 2 months ago 37MB
ubuntu/squid latest e830c46c0231 3 months ago 288MB
semitechnologies/weaviate 1.19.0 b7fde6d5a98e 20 months ago 51MB
-
mkdir -p docker_images
cd docker_images
-
docker save langgenius/dify-web:0.14.2 -o dify-web.tar
docker save langgenius/dify-api:0.14.2 -o dify-api.tar
docker save postgres:15-alpine -o postgres.tar
docker save nginx:latest -o nginx.tar
docker save langgenius/dify-sandbox:0.2.10 -o dify-sandbox.tar
docker save redis:6-alpine -o redis.tar
docker save ubuntu/squid:latest -o squid.tar
docker save semitechnologies/weaviate:1.19.0 -o weaviate.tar
-
-
-
docker_images 目录(包含所有 .tar 文件)
2.2 在生产环境中部署
-
-
cd docker_images
docker load -i dify-web.tar
docker load -i dify-api.tar
docker load -i postgres.tar
docker load -i nginx.tar
docker load -i dify-sandbox.tar
docker load -i redis.tar
docker load -i squid.tar
docker load -i weaviate.tar
-
cd ../docker
cp .env.example .env
# 编辑 .env 文件,配置必要的环境变量
-
docker compose up -d
3. 前端开发指南
如果需要修改前端页面,可以采用本地开发方式:
-