chore: format

This commit is contained in:
Sun-ZhenXing
2026-01-01 17:18:52 +08:00
parent 1c33225b70
commit 9c25970445
36 changed files with 450 additions and 300 deletions

28
apps/dify/.env.example Normal file
View 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
apps/dify/README.md Normal file
View 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
apps/dify/README.zh.md Normal file
View 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)。

View File

@@ -0,0 +1,201 @@
x-defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
dify-api:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}langgenius/dify-api:${DIFY_VERSION:-0.18.2}
depends_on:
dify-db:
condition: service_healthy
dify-redis:
condition: service_healthy
environment:
- TZ=${TZ:-UTC}
- 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:
- dify_storage:/app/api/storage
deploy:
resources:
limits:
cpus: ${DIFY_API_CPU_LIMIT:-1.0}
memory: ${DIFY_API_MEMORY_LIMIT:-2G}
reservations:
cpus: ${DIFY_API_CPU_RESERVATION:-0.5}
memory: ${DIFY_API_MEMORY_RESERVATION:-1G}
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:5001/health",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
dify-worker:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}langgenius/dify-api:${DIFY_VERSION:-0.18.2}
depends_on:
dify-db:
condition: service_healthy
dify-redis:
condition: service_healthy
environment:
- TZ=${TZ:-UTC}
- 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:
- dify_storage:/app/api/storage
deploy:
resources:
limits:
cpus: ${DIFY_WORKER_CPU_LIMIT:-1.0}
memory: ${DIFY_WORKER_MEMORY_LIMIT:-2G}
reservations:
cpus: ${DIFY_WORKER_CPU_RESERVATION:-0.5}
memory: ${DIFY_WORKER_MEMORY_RESERVATION:-1G}
dify-web:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}langgenius/dify-web:${DIFY_VERSION:-0.18.2}
depends_on:
dify-api:
condition: service_healthy
environment:
- TZ=${TZ:-UTC}
- 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: ${DIFY_WEB_CPU_LIMIT:-0.5}
memory: ${DIFY_WEB_MEMORY_LIMIT:-512M}
reservations:
cpus: ${DIFY_WEB_CPU_RESERVATION:-0.25}
memory: ${DIFY_WEB_MEMORY_RESERVATION:-256M}
dify-db:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}postgres:15-alpine
environment:
- TZ=${TZ:-UTC}
- POSTGRES_USER=${POSTGRES_USER:-dify}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-difypass}
- POSTGRES_DB=${POSTGRES_DB:-dify}
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- dify_db_data:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: ${DIFY_DB_CPU_LIMIT:-0.5}
memory: ${DIFY_DB_MEMORY_LIMIT:-512M}
reservations:
cpus: ${DIFY_DB_CPU_RESERVATION:-0.25}
memory: ${DIFY_DB_MEMORY_RESERVATION:-256M}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
dify-redis:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD:-}
environment:
- TZ=${TZ:-UTC}
volumes:
- dify_redis_data:/data
deploy:
resources:
limits:
cpus: ${DIFY_REDIS_CPU_LIMIT:-0.25}
memory: ${DIFY_REDIS_MEMORY_LIMIT:-256M}
reservations:
cpus: ${DIFY_REDIS_CPU_RESERVATION:-0.1}
memory: ${DIFY_REDIS_MEMORY_RESERVATION:-128M}
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
start_period: 5s
dify-weaviate:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}semitechnologies/weaviate:${WEAVIATE_VERSION:-1.28.12}
profiles:
- weaviate
environment:
- TZ=${TZ:-UTC}
- QUERY_DEFAULTS_LIMIT=25
- AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true
- PERSISTENCE_DATA_PATH=/var/lib/weaviate
- DEFAULT_VECTORIZER_MODULE=none
- CLUSTER_HOSTNAME=node1
volumes:
- dify_weaviate_data:/var/lib/weaviate
deploy:
resources:
limits:
cpus: ${DIFY_WEAVIATE_CPU_LIMIT:-0.5}
memory: ${DIFY_WEAVIATE_MEMORY_LIMIT:-1G}
reservations:
cpus: ${DIFY_WEAVIATE_CPU_RESERVATION:-0.25}
memory: ${DIFY_WEAVIATE_MEMORY_RESERVATION:-512M}
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:8080/v1/.well-known/ready",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
volumes:
dify_storage:
dify_db_data:
dify_redis_data:
dify_weaviate_data:

View File

@@ -88,7 +88,15 @@ services:
cpus: ${LANGFUSE_WORKER_CPU_RESERVATION:-0.5}
memory: ${LANGFUSE_WORKER_MEMORY_RESERVATION:-512M}
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3030/api/health"]
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://127.0.0.1:3030/api/health",
]
interval: 30s
timeout: 10s
retries: 3
@@ -122,7 +130,15 @@ services:
cpus: ${LANGFUSE_WEB_CPU_RESERVATION:-0.5}
memory: ${LANGFUSE_WEB_MEMORY_RESERVATION:-512M}
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/api/public/health"]
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://127.0.0.1:3000/api/public/health",
]
interval: 30s
timeout: 10s
retries: 3
@@ -131,6 +147,8 @@ services:
clickhouse:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}clickhouse/clickhouse-server:${CLICKHOUSE_VERSION:-latest}
profiles:
- ${COMPOSE_PROFILES:-}
user: "101:101"
environment:
CLICKHOUSE_DB: default
@@ -160,7 +178,9 @@ services:
minio:
<<: *defaults
image: ${CGR_DEV_REGISTRY:-cgr.dev/}chainguard/minio:${MINIO_VERSION:-latest}
image: ${CGR_DEV_REGISTRY:-cgr.dev}/chainguard/minio:${MINIO_VERSION:-latest}
profiles:
- ${COMPOSE_PROFILES:-}
entrypoint: sh
# create the 'langfuse' bucket before starting the service
command: -c 'mkdir -p /data/langfuse && minio server --address ":9000" --console-address ":9001" /data'
@@ -188,6 +208,8 @@ services:
redis:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}redis:${REDIS_VERSION:-7}
profiles:
- ${COMPOSE_PROFILES:-}
command: >
--requirepass ${REDIS_AUTH:-myredissecret}
--maxmemory-policy noeviction
@@ -208,6 +230,8 @@ services:
postgres:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}postgres:${POSTGRES_VERSION:-17}
profiles:
- ${COMPOSE_PROFILES:-}
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}