feat: add more
This commit is contained in:
28
src/dify/.env.example
Normal file
28
src/dify/.env.example
Normal file
@@ -0,0 +1,28 @@
|
||||
# Dify version
|
||||
DIFY_VERSION="0.18.2"
|
||||
|
||||
# Database configuration
|
||||
POSTGRES_USER="dify"
|
||||
POSTGRES_PASSWORD="difypass"
|
||||
POSTGRES_DB="dify"
|
||||
|
||||
# Redis configuration
|
||||
REDIS_PASSWORD=""
|
||||
|
||||
# Application configuration
|
||||
SECRET_KEY="sk-xxxxxx"
|
||||
LOG_LEVEL="INFO"
|
||||
|
||||
# API URLs
|
||||
DIFY_API_URL="http://localhost:5001"
|
||||
DIFY_APP_URL="http://localhost:3000"
|
||||
|
||||
# Port override
|
||||
DIFY_PORT_OVERRIDE=3000
|
||||
|
||||
# Storage type: local, s3, azure-blob, etc.
|
||||
STORAGE_TYPE="local"
|
||||
|
||||
# Vector store type: weaviate, milvus, qdrant, etc.
|
||||
VECTOR_STORE="weaviate"
|
||||
WEAVIATE_VERSION="1.28.12"
|
||||
84
src/dify/README.md
Normal file
84
src/dify/README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Dify
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
This service deploys Dify, an LLM app development platform that combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more.
|
||||
|
||||
## Services
|
||||
|
||||
- `dify-api`: API service for Dify
|
||||
- `dify-worker`: Background worker for async tasks
|
||||
- `dify-web`: Web frontend interface
|
||||
- `dify-db`: PostgreSQL database
|
||||
- `dify-redis`: Redis cache
|
||||
- `dify-weaviate`: Weaviate vector database (optional profile)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable Name | Description | Default Value |
|
||||
| ------------------ | ------------------------------------------ | ------------- |
|
||||
| DIFY_VERSION | Dify image version | `0.18.2` |
|
||||
| POSTGRES_USER | PostgreSQL username | `dify` |
|
||||
| POSTGRES_PASSWORD | PostgreSQL password | `difypass` |
|
||||
| POSTGRES_DB | PostgreSQL database name | `dify` |
|
||||
| REDIS_PASSWORD | Redis password (empty for no auth) | `""` |
|
||||
| SECRET_KEY | Secret key for encryption | (auto) |
|
||||
| LOG_LEVEL | Log level | `INFO` |
|
||||
| DIFY_PORT_OVERRIDE | Host port mapping for web interface | `3000` |
|
||||
| STORAGE_TYPE | Storage type (local, s3, azure-blob, etc.) | `local` |
|
||||
| VECTOR_STORE | Vector store type (weaviate, milvus, etc.) | `weaviate` |
|
||||
| WEAVIATE_VERSION | Weaviate version (if using weaviate) | `1.28.12` |
|
||||
|
||||
Please modify the `.env` file as needed for your use case.
|
||||
|
||||
## Volumes
|
||||
|
||||
- `dify_storage`: Storage for uploaded files and generated content
|
||||
- `dify_db_data`: PostgreSQL data
|
||||
- `dify_redis_data`: Redis persistence data
|
||||
- `dify_weaviate_data`: Weaviate vector database data
|
||||
|
||||
## Usage
|
||||
|
||||
### Start Dify with Weaviate
|
||||
|
||||
```bash
|
||||
docker compose --profile weaviate up -d
|
||||
```
|
||||
|
||||
### Start Dify without Vector Database
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Access
|
||||
|
||||
- Web Interface: <http://localhost:3000>
|
||||
- API Docs: <http://localhost:5001/docs>
|
||||
|
||||
### First Time Setup
|
||||
|
||||
1. Open <http://localhost:3000>
|
||||
2. Create an admin account
|
||||
3. Configure your LLM API keys (OpenAI, Azure OpenAI, Anthropic, etc.)
|
||||
4. Start creating your AI applications
|
||||
|
||||
## Notes
|
||||
|
||||
- First startup may take a few minutes for database initialization
|
||||
- Change `SECRET_KEY` in production for security
|
||||
- For production deployment, consider using external PostgreSQL and Redis
|
||||
- Supports multiple LLM providers: OpenAI, Azure OpenAI, Anthropic, Google, local models via Ollama, etc.
|
||||
- Vector database is optional but recommended for RAG capabilities
|
||||
|
||||
## Security
|
||||
|
||||
- Change default passwords in production
|
||||
- Use strong `SECRET_KEY`
|
||||
- Enable authentication on Redis in production
|
||||
- Consider using TLS for API connections in production
|
||||
|
||||
## License
|
||||
|
||||
Dify is licensed under Apache License 2.0. See [Dify GitHub](https://github.com/langgenius/dify) for more information.
|
||||
84
src/dify/README.zh.md
Normal file
84
src/dify/README.zh.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Dify
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
这个服务部署 Dify,一个 LLM 应用开发平台,结合了 AI 工作流、RAG 管道、代理能力、模型管理、可观测性功能等。
|
||||
|
||||
## 服务
|
||||
|
||||
- `dify-api`: Dify API 服务
|
||||
- `dify-worker`: 后台异步任务 Worker
|
||||
- `dify-web`: Web 前端界面
|
||||
- `dify-db`: PostgreSQL 数据库
|
||||
- `dify-redis`: Redis 缓存
|
||||
- `dify-weaviate`: Weaviate 向量数据库(可选 profile)
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量名 | 描述 | 默认值 |
|
||||
| ------------------ | --------------------------------- | ---------- |
|
||||
| DIFY_VERSION | Dify 镜像版本 | `0.18.2` |
|
||||
| POSTGRES_USER | PostgreSQL 用户名 | `dify` |
|
||||
| POSTGRES_PASSWORD | PostgreSQL 密码 | `difypass` |
|
||||
| POSTGRES_DB | PostgreSQL 数据库名 | `dify` |
|
||||
| REDIS_PASSWORD | Redis 密码(留空则不需要认证) | `""` |
|
||||
| SECRET_KEY | 加密密钥 | (自动) |
|
||||
| LOG_LEVEL | 日志级别 | `INFO` |
|
||||
| DIFY_PORT_OVERRIDE | Web 界面主机端口映射 | `3000` |
|
||||
| STORAGE_TYPE | 存储类型(local, s3, azure-blob等) | `local` |
|
||||
| VECTOR_STORE | 向量库类型(weaviate, milvus等) | `weaviate` |
|
||||
| WEAVIATE_VERSION | Weaviate 版本(如果使用weaviate) | `1.28.12` |
|
||||
|
||||
请根据您的需求修改 `.env` 文件。
|
||||
|
||||
## 数据卷
|
||||
|
||||
- `dify_storage`: 上传文件和生成内容的存储
|
||||
- `dify_db_data`: PostgreSQL 数据
|
||||
- `dify_redis_data`: Redis 持久化数据
|
||||
- `dify_weaviate_data`: Weaviate 向量数据库数据
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 启动 Dify 与 Weaviate
|
||||
|
||||
```bash
|
||||
docker compose --profile weaviate up -d
|
||||
```
|
||||
|
||||
### 启动 Dify 不含向量数据库
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 访问
|
||||
|
||||
- Web 界面: <http://localhost:3000>
|
||||
- API 文档: <http://localhost:5001/docs>
|
||||
|
||||
### 首次设置
|
||||
|
||||
1. 打开 <http://localhost:3000>
|
||||
2. 创建管理员账户
|
||||
3. 配置您的 LLM API 密钥(OpenAI、Azure OpenAI、Anthropic 等)
|
||||
4. 开始创建您的 AI 应用
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 首次启动可能需要几分钟进行数据库初始化
|
||||
- 生产环境请修改 `SECRET_KEY` 以提高安全性
|
||||
- 生产环境建议使用外部 PostgreSQL 和 Redis
|
||||
- 支持多种 LLM 提供商:OpenAI、Azure OpenAI、Anthropic、Google、通过 Ollama 的本地模型等
|
||||
- 向量数据库是可选的,但建议用于 RAG 功能
|
||||
|
||||
## 安全性
|
||||
|
||||
- 生产环境请修改默认密码
|
||||
- 使用强 `SECRET_KEY`
|
||||
- 生产环境在 Redis 上启用认证
|
||||
- 生产环境考虑为 API 连接使用 TLS
|
||||
|
||||
## 许可证
|
||||
|
||||
Dify 采用 Apache License 2.0 许可。更多信息请参见 [Dify GitHub](https://github.com/langgenius/dify)。
|
||||
167
src/dify/docker-compose.yaml
Normal file
167
src/dify/docker-compose.yaml
Normal file
@@ -0,0 +1,167 @@
|
||||
x-default: &default
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- &localtime /etc/localtime:/etc/localtime:ro
|
||||
- &timezone /etc/timezone:/etc/timezone:ro
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 100m
|
||||
|
||||
services:
|
||||
dify-api:
|
||||
<<: *default
|
||||
image: langgenius/dify-api:${DIFY_VERSION:-0.18.2}
|
||||
container_name: dify-api
|
||||
depends_on:
|
||||
- dify-db
|
||||
- dify-redis
|
||||
environment:
|
||||
- MODE=api
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
- SECRET_KEY=${SECRET_KEY:-sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U}
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER:-dify}:${POSTGRES_PASSWORD:-difypass}@dify-db:5432/${POSTGRES_DB:-dify}
|
||||
- REDIS_HOST=dify-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_DB=0
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
||||
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-}@dify-redis:6379/1
|
||||
- STORAGE_TYPE=${STORAGE_TYPE:-local}
|
||||
- VECTOR_STORE=${VECTOR_STORE:-weaviate}
|
||||
- WEAVIATE_ENDPOINT=http://dify-weaviate:8080
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- dify_storage:/app/api/storage
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 1G
|
||||
|
||||
dify-worker:
|
||||
<<: *default
|
||||
image: langgenius/dify-api:${DIFY_VERSION:-0.18.2}
|
||||
container_name: dify-worker
|
||||
depends_on:
|
||||
- dify-db
|
||||
- dify-redis
|
||||
environment:
|
||||
- MODE=worker
|
||||
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||
- SECRET_KEY=${SECRET_KEY:-sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U}
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER:-dify}:${POSTGRES_PASSWORD:-difypass}@dify-db:5432/${POSTGRES_DB:-dify}
|
||||
- REDIS_HOST=dify-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_DB=0
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
|
||||
- CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-}@dify-redis:6379/1
|
||||
- STORAGE_TYPE=${STORAGE_TYPE:-local}
|
||||
- VECTOR_STORE=${VECTOR_STORE:-weaviate}
|
||||
- WEAVIATE_ENDPOINT=http://dify-weaviate:8080
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- dify_storage:/app/api/storage
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 1G
|
||||
|
||||
dify-web:
|
||||
<<: *default
|
||||
image: langgenius/dify-web:${DIFY_VERSION:-0.18.2}
|
||||
container_name: dify-web
|
||||
depends_on:
|
||||
- dify-api
|
||||
environment:
|
||||
- NEXT_PUBLIC_API_URL=${DIFY_API_URL:-http://localhost:5001}
|
||||
- NEXT_PUBLIC_APP_URL=${DIFY_APP_URL:-http://localhost:3000}
|
||||
ports:
|
||||
- "${DIFY_PORT_OVERRIDE:-3000}:3000"
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
dify-db:
|
||||
<<: *default
|
||||
image: postgres:15-alpine
|
||||
container_name: dify-db
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER:-dify}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-difypass}
|
||||
- POSTGRES_DB=${POSTGRES_DB:-dify}
|
||||
- PGDATA=/var/lib/postgresql/data/pgdata
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- dify_db_data:/var/lib/postgresql/data
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
dify-redis:
|
||||
<<: *default
|
||||
image: redis:7-alpine
|
||||
container_name: dify-redis
|
||||
command: redis-server --requirepass ${REDIS_PASSWORD:-}
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- dify_redis_data:/data
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
reservations:
|
||||
cpus: '0.1'
|
||||
memory: 128M
|
||||
|
||||
dify-weaviate:
|
||||
<<: *default
|
||||
image: semitechnologies/weaviate:${WEAVIATE_VERSION:-1.28.12}
|
||||
container_name: dify-weaviate
|
||||
profiles:
|
||||
- weaviate
|
||||
environment:
|
||||
- QUERY_DEFAULTS_LIMIT=25
|
||||
- AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true
|
||||
- PERSISTENCE_DATA_PATH=/var/lib/weaviate
|
||||
- DEFAULT_VECTORIZER_MODULE=none
|
||||
- CLUSTER_HOSTNAME=node1
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- dify_weaviate_data:/var/lib/weaviate
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.5'
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 512M
|
||||
|
||||
volumes:
|
||||
dify_storage:
|
||||
dify_db_data:
|
||||
dify_redis_data:
|
||||
dify_weaviate_data:
|
||||
Reference in New Issue
Block a user