feat: add openlit & openobserve & buildingai

This commit is contained in:
Sun-ZhenXing
2026-01-15 09:12:18 +08:00
parent b3c2708a53
commit 3efc2150fe
14 changed files with 1741 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
# BuildingAI Configuration
# Copy this file to .env and modify as needed
# ===========================
# Global Settings
# ===========================
# Global registry prefix for all images (optional)
# Example: registry.example.com/
GLOBAL_REGISTRY=
# Timezone setting (default: UTC)
# Examples: Asia/Shanghai, America/New_York, Europe/London
TZ=UTC
# ===========================
# Redis Configuration
# ===========================
# Redis version
REDIS_VERSION=8.2.2
# Redis password (leave empty for no password)
REDIS_PASSWORD=
# Redis host port override (default: 6379)
# Set this to change the exposed port on the host
REDIS_PORT_OVERRIDE=6379
# Redis resource limits
REDIS_CPU_LIMIT=0.25
REDIS_MEMORY_LIMIT=256M
REDIS_CPU_RESERVATION=0.10
REDIS_MEMORY_RESERVATION=128M
# ===========================
# PostgreSQL Configuration
# ===========================
# PostgreSQL version
POSTGRES_VERSION=17.6-alpine
# Database credentials
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE=buildingai
# PostgreSQL host port override (default: 5432)
POSTGRES_PORT_OVERRIDE=5432
# PostgreSQL resource limits
POSTGRES_CPU_LIMIT=1.0
POSTGRES_MEMORY_LIMIT=512M
POSTGRES_CPU_RESERVATION=0.25
POSTGRES_MEMORY_RESERVATION=256M
# ===========================
# BuildingAI Configuration
# ===========================
# BuildingAI version
BUILDINGAI_VERSION=latest
# Server port (internal container port)
SERVER_PORT=4090
# BuildingAI host port override (default: 4090)
# This is the port you'll use to access BuildingAI
BUILDINGAI_PORT_OVERRIDE=4090
# NPM Registry URL (optional)
# Set this to use a custom npm registry mirror
# Example: https://registry.npmmirror.com
NPM_REGISTRY_URL=
# BuildingAI resource limits
BUILDINGAI_CPU_LIMIT=2.0
BUILDINGAI_MEMORY_LIMIT=3584M
BUILDINGAI_CPU_RESERVATION=0.5
BUILDINGAI_MEMORY_RESERVATION=512M

231
apps/buildingai/README.md Normal file
View File

@@ -0,0 +1,231 @@
# BuildingAI
BuildingAI is an intelligent AI application development platform that empowers developers to quickly build and deploy AI-powered applications. Built on NestJS + Vue 3, it provides a comprehensive solution for creating, managing, and deploying AI agents with a modern, user-friendly interface.
## Features
- 🤖 **AI Agent Builder**: Create and customize AI agents with drag-and-drop interface
- 💬 **Conversation Management**: Advanced chat interface with context awareness
- 🔌 **MCP Server Integration**: Support for Model Context Protocol servers
- 🎨 **Modern UI**: Built with Vue 3 and Nuxt for excellent user experience
- 🔒 **Enterprise Ready**: Built-in user management, authentication, and multi-tenancy
- 📊 **Analytics**: Track usage and performance of your AI applications
- 🌐 **i18n Support**: Multi-language interface support
- 🔧 **Extensible**: Plugin system for custom extensions
## Tech Stack
- **Backend**: NestJS 11.x + TypeORM 0.3.x
- **Database**: PostgreSQL 17.x
- **Cache**: Redis 8.x
- **Frontend**: Vue.js 3.x + Nuxt + Vite 7.x
- **TypeScript**: 5.x
- **Monorepo**: Turbo 2.x
## Quick Start
### Prerequisites
- Docker and Docker Compose installed
- At least 4GB RAM available
- 5GB free disk space
### Deployment
1. Copy the environment file:
```bash
cp .env.example .env
```
2. (Optional) Modify the `.env` file to customize your configuration:
- Set `DB_PASSWORD` for database security
- Set `REDIS_PASSWORD` for Redis security
- Configure `BUILDINGAI_PORT_OVERRIDE` if you need a different port
- Set `NPM_REGISTRY_URL` if you need a custom npm registry mirror
3. Start the services:
```bash
docker compose up -d
```
4. Wait for services to be ready (may take a few minutes on first start):
```bash
docker compose logs -f buildingai
```
5. Access BuildingAI at [http://localhost:4090/install](http://localhost:4090/install) to complete the initial setup wizard.
### Default Ports
- **BuildingAI**: 4090 (web interface)
- **PostgreSQL**: 5432 (database)
- **Redis**: 6379 (cache)
You can override these ports in the `.env` file.
## Configuration
### Environment Variables
All configuration is done through the `.env` file. See [.env.example](.env.example) for all available options.
#### Key Settings
- `DB_USERNAME` / `DB_PASSWORD`: Database credentials
- `REDIS_PASSWORD`: Redis password (optional, but recommended for production)
- `SERVER_PORT`: Internal application port
- `NPM_REGISTRY_URL`: Custom npm registry mirror (useful in China or private networks)
### Resource Limits
Default resource limits are configured for small to medium deployments:
- **BuildingAI**: 2 CPU cores, 3584MB RAM
- **PostgreSQL**: 1 CPU core, 512MB RAM
- **Redis**: 0.25 CPU cores, 256MB RAM
Adjust these in `.env` based on your workload.
## Data Persistence
All data is stored in Docker volumes:
- `buildingai_data`: Application data and uploads
- `postgres_data`: Database files
- `redis_data`: Redis persistence
### Backup
To backup your data:
```bash
# Backup database
docker compose exec postgres pg_dump -U postgres buildingai > backup.sql
# Backup application data
docker run --rm -v buildingai_buildingai_data:/data -v $(pwd):/backup alpine tar czf /backup/buildingai-data.tar.gz -C /data .
```
### Restore
```bash
# Restore database
docker compose exec -T postgres psql -U postgres buildingai < backup.sql
# Restore application data
docker run --rm -v buildingai_buildingai_data:/data -v $(pwd):/backup alpine tar xzf /backup/buildingai-data.tar.gz -C /data
```
## Maintenance
### View Logs
```bash
# All services
docker compose logs -f
# Specific service
docker compose logs -f buildingai
```
### Restart Services
```bash
# All services
docker compose restart
# Specific service
docker compose restart buildingai
```
### Update BuildingAI
```bash
# Pull latest images
docker compose pull
# Restart with new images
docker compose up -d
```
### Stop Services
```bash
# Stop all services
docker compose down
# Stop and remove volumes (WARNING: deletes all data)
docker compose down -v
```
## Troubleshooting
### BuildingAI won't start
1. Check service health:
```bash
docker compose ps
```
2. Check logs for errors:
```bash
docker compose logs buildingai
```
3. Ensure PostgreSQL and Redis are healthy:
```bash
docker compose ps postgres redis
```
### Database connection errors
- Verify `DB_USERNAME`, `DB_PASSWORD`, and `DB_DATABASE` in `.env`
- Check PostgreSQL logs: `docker compose logs postgres`
- Ensure PostgreSQL healthcheck is passing
### Redis connection errors
- If `REDIS_PASSWORD` is set, ensure it matches in all services
- Check Redis logs: `docker compose logs redis`
- Verify Redis healthcheck status
### Performance issues
- Increase resource limits in `.env`
- Monitor resource usage: `docker stats`
- Check for sufficient disk space
## Security Recommendations
For production deployments:
1. **Set strong passwords** for `DB_PASSWORD` and `REDIS_PASSWORD`
2. **Do not expose** PostgreSQL and Redis ports externally (remove port mappings or use firewall rules)
3. **Use a reverse proxy** (nginx, Caddy) with HTTPS for the BuildingAI web interface
4. **Regular backups** of database and application data
5. **Monitor logs** for suspicious activity
6. **Keep images updated** regularly
## Links
- [GitHub Repository](https://github.com/BidingCC/BuildingAI)
- [Official Website](https://www.buildingai.cc/)
- [Live Demo](http://demo.buildingai.cc/)
- [Documentation](https://www.buildingai.cc/docs/introduction/install)
## License
Please refer to the [original repository](https://github.com/BidingCC/BuildingAI) for license information.
## Support
For issues and questions:
- GitHub Issues: [BuildingAI Issues](https://github.com/BidingCC/BuildingAI/issues)
- Official Documentation: [BuildingAI Docs](https://www.buildingai.cc/docs/)

View File

@@ -0,0 +1,231 @@
# BuildingAI
BuildingAI 是一个智能 AI 应用开发平台,帮助开发者快速构建和部署 AI 驱动的应用程序。基于 NestJS + Vue 3 构建,为创建、管理和部署 AI 智能体提供全面的解决方案,拥有现代化的用户友好界面。
## 功能特性
- 🤖 **AI 智能体构建器**:使用拖放界面创建和自定义 AI 智能体
- 💬 **对话管理**:具有上下文感知的高级聊天界面
- 🔌 **MCP 服务器集成**支持模型上下文协议Model Context Protocol服务器
- 🎨 **现代化 UI**:使用 Vue 3 和 Nuxt 构建,提供卓越的用户体验
- 🔒 **企业级就绪**:内置用户管理、身份验证和多租户支持
- 📊 **数据分析**:跟踪 AI 应用的使用情况和性能
- 🌐 **i18n 支持**:多语言界面支持
- 🔧 **可扩展**:插件系统支持自定义扩展
## 技术栈
- **后端**NestJS 11.x + TypeORM 0.3.x
- **数据库**PostgreSQL 17.x
- **缓存**Redis 8.x
- **前端**Vue.js 3.x + Nuxt + Vite 7.x
- **TypeScript**5.x
- **Monorepo**Turbo 2.x
## 快速开始
### 前置要求
- 已安装 Docker 和 Docker Compose
- 至少 4GB 可用内存
- 5GB 可用磁盘空间
### 部署步骤
1. 复制环境变量文件:
```bash
cp .env.example .env
```
2. (可选)修改 `.env` 文件以自定义配置:
- 设置 `DB_PASSWORD` 以增强数据库安全性
- 设置 `REDIS_PASSWORD` 以增强 Redis 安全性
- 如需使用不同端口,配置 `BUILDINGAI_PORT_OVERRIDE`
- 如需使用自定义 npm 镜像源,设置 `NPM_REGISTRY_URL`
3. 启动服务:
```bash
docker compose up -d
```
4. 等待服务就绪(首次启动可能需要几分钟):
```bash
docker compose logs -f buildingai
```
5. 访问 [http://localhost:4090/install](http://localhost:4090/install) 完成初始化设置向导。
### 默认端口
- **BuildingAI**4090Web 界面)
- **PostgreSQL**5432数据库
- **Redis**6379缓存
你可以在 `.env` 文件中覆盖这些端口。
## 配置说明
### 环境变量
所有配置都通过 `.env` 文件完成。查看 [.env.example](.env.example) 了解所有可用选项。
#### 关键设置
- `DB_USERNAME` / `DB_PASSWORD`:数据库凭据
- `REDIS_PASSWORD`Redis 密码(可选,但生产环境建议设置)
- `SERVER_PORT`:内部应用端口
- `NPM_REGISTRY_URL`:自定义 npm 镜像源(在中国或私有网络中很有用)
### 资源限制
默认资源限制配置适用于中小型部署:
- **BuildingAI**2 CPU 核心3584MB 内存
- **PostgreSQL**1 CPU 核心512MB 内存
- **Redis**0.25 CPU 核心256MB 内存
根据你的工作负载在 `.env` 中调整这些设置。
## 数据持久化
所有数据存储在 Docker 卷中:
- `buildingai_data`:应用数据和上传文件
- `postgres_data`:数据库文件
- `redis_data`Redis 持久化数据
### 备份
备份你的数据:
```bash
# 备份数据库
docker compose exec postgres pg_dump -U postgres buildingai > backup.sql
# 备份应用数据
docker run --rm -v buildingai_buildingai_data:/data -v $(pwd):/backup alpine tar czf /backup/buildingai-data.tar.gz -C /data .
```
### 恢复
```bash
# 恢复数据库
docker compose exec -T postgres psql -U postgres buildingai < backup.sql
# 恢复应用数据
docker run --rm -v buildingai_buildingai_data:/data -v $(pwd):/backup alpine tar xzf /backup/buildingai-data.tar.gz -C /data
```
## 维护
### 查看日志
```bash
# 所有服务
docker compose logs -f
# 特定服务
docker compose logs -f buildingai
```
### 重启服务
```bash
# 所有服务
docker compose restart
# 特定服务
docker compose restart buildingai
```
### 更新 BuildingAI
```bash
# 拉取最新镜像
docker compose pull
# 使用新镜像重启
docker compose up -d
```
### 停止服务
```bash
# 停止所有服务
docker compose down
# 停止并删除卷(警告:会删除所有数据)
docker compose down -v
```
## 故障排除
### BuildingAI 无法启动
1. 检查服务健康状态:
```bash
docker compose ps
```
2. 检查日志中的错误:
```bash
docker compose logs buildingai
```
3. 确保 PostgreSQL 和 Redis 健康:
```bash
docker compose ps postgres redis
```
### 数据库连接错误
- 验证 `.env` 中的 `DB_USERNAME`、`DB_PASSWORD` 和 `DB_DATABASE`
- 检查 PostgreSQL 日志:`docker compose logs postgres`
- 确保 PostgreSQL 健康检查通过
### Redis 连接错误
- 如果设置了 `REDIS_PASSWORD`,确保所有服务中的配置一致
- 检查 Redis 日志:`docker compose logs redis`
- 验证 Redis 健康检查状态
### 性能问题
- 在 `.env` 中增加资源限制
- 监控资源使用情况:`docker stats`
- 检查磁盘空间是否充足
## 安全建议
生产环境部署时:
1. **设置强密码**:为 `DB_PASSWORD` 和 `REDIS_PASSWORD` 设置强密码
2. **不要暴露端口**:不要在外部暴露 PostgreSQL 和 Redis 端口(删除端口映射或使用防火墙规则)
3. **使用反向代理**:为 BuildingAI Web 界面使用带 HTTPS 的反向代理nginx、Caddy
4. **定期备份**:定期备份数据库和应用数据
5. **监控日志**:监控日志中的可疑活动
6. **保持更新**:定期更新镜像
## 链接
- [GitHub 仓库](https://github.com/BidingCC/BuildingAI)
- [官方网站](https://www.buildingai.cc/)
- [在线演示](http://demo.buildingai.cc/)
- [文档](https://www.buildingai.cc/docs/introduction/install)
## 许可证
请参考[原始仓库](https://github.com/BidingCC/BuildingAI)了解许可证信息。
## 支持
遇到问题和疑问:
- GitHub Issues[BuildingAI Issues](https://github.com/BidingCC/BuildingAI/issues)
- 官方文档:[BuildingAI Docs](https://www.buildingai.cc/docs/)

View File

@@ -0,0 +1,117 @@
# BuildingAI - AI Application Development Platform
# An intelligent application development platform built on NestJS + Vue 3
# https://github.com/BidingCC/BuildingAI
x-defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
redis:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}redis:${REDIS_VERSION:-8.2.2}-alpine
environment:
- TZ=${TZ:-UTC}
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
ports:
- "${REDIS_PORT_OVERRIDE:-6379}:6379"
volumes:
- redis_data:/data
command: >
sh -c '
if [ -n "$REDIS_PASSWORD" ]; then
exec redis-server --requirepass "$REDIS_PASSWORD"
else
exec redis-server
fi
'
healthcheck:
test: ["CMD-SHELL", "redis-cli -a $$REDIS_PASSWORD ping 2>/dev/null || redis-cli ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
cpus: ${REDIS_CPU_LIMIT:-0.25}
memory: ${REDIS_MEMORY_LIMIT:-256M}
reservations:
cpus: ${REDIS_CPU_RESERVATION:-0.10}
memory: ${REDIS_MEMORY_RESERVATION:-128M}
postgres:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}postgres:${POSTGRES_VERSION:-17.6-alpine}
environment:
- TZ=${TZ:-UTC}
- POSTGRES_USER=${DB_USERNAME:-postgres}
- POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}
- POSTGRES_DB=${DB_DATABASE:-buildingai}
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- "${POSTGRES_PORT_OVERRIDE:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
deploy:
resources:
limits:
cpus: ${POSTGRES_CPU_LIMIT:-1.0}
memory: ${POSTGRES_MEMORY_LIMIT:-512M}
reservations:
cpus: ${POSTGRES_CPU_RESERVATION:-0.25}
memory: ${POSTGRES_MEMORY_RESERVATION:-256M}
buildingai:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}bidingcc/buildingai:${BUILDINGAI_VERSION:-latest}
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
environment:
- TZ=${TZ:-UTC}
- SERVER_PORT=${SERVER_PORT:-4090}
- NPM_REGISTRY_URL=${NPM_REGISTRY_URL:-}
- DB_USERNAME=${DB_USERNAME:-postgres}
- DB_PASSWORD=${DB_PASSWORD:-postgres}
- DB_DATABASE=${DB_DATABASE:-buildingai}
- DB_HOST=postgres
- DB_PORT=5432
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-}
ports:
- "${BUILDINGAI_PORT_OVERRIDE:-4090}:${SERVER_PORT:-4090}"
volumes:
- buildingai_data:/app/data
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:${SERVER_PORT:-4090}/consoleapi/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 180s
deploy:
resources:
limits:
cpus: ${BUILDINGAI_CPU_LIMIT:-2.0}
memory: ${BUILDINGAI_MEMORY_LIMIT:-3584M}
reservations:
cpus: ${BUILDINGAI_CPU_RESERVATION:-0.5}
memory: ${BUILDINGAI_MEMORY_RESERVATION:-512M}
volumes:
redis_data:
postgres_data:
buildingai_data: