This commit is contained in:
HuYing 2025-12-11 21:38:31 +08:00 committed by GitHub
commit c9de3e8693
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 257 additions and 3 deletions

6
Dockerfile-server-arm Normal file
View file

@ -0,0 +1,6 @@
FROM xiaozhi-esp32-server:server-base
WORKDIR /opt/xiaozhi-esp32-server
COPY main/xiaozhi-server .
CMD ["python", "app.py"]

View file

@ -185,6 +185,7 @@ Spearheaded by Professor Siyuan Liu's Team (South China University of Technology
|---------|------|---------|---------|---------|---------|
| **最简化安装** | 智能对话、IOT、MCP、视觉感知 | 低配置环境,数据存储在配置文件,无需数据库 | [①Docker版](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②源码部署](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%8F%AA%E8%BF%90%E8%A1%8Cserver)| 如果使用`FunASR`要2核4G,如果全API,要2核2G | - |
| **全模块安装** | 智能对话、IOT、MCP接入点、声纹识别、视觉感知、OTA、智控台 | 完整功能体验,数据存储在数据库 |[①Docker版](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [②源码部署](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [③源码部署自动更新教程](./docs/dev-ops-integration.md) | 如果使用`FunASR`要4核8G,如果全API,要2核4G| [本地源码启动视频教程](https://www.bilibili.com/video/BV1wBJhz4Ewe) |
| **ARM64设备部署** | 适用于树莓派、Jetson Nano等低功耗ARM64设备 | 轻量化部署,适合开发和小规模应用 | [Docker ARM64部署](./docs/docker-build.md) | 需要树莓派4 8GB及以上配置 | - |
常见问题及相关教程,可参考[这个链接](./docs/FAQ.md)

View file

@ -183,6 +183,7 @@ This project provides two deployment methods. Please choose based on your specif
|---------|------|---------|---------|---------|---------|
| **Simplified Installation** | Intelligent dialogue, IOT, MCP, visual perception | Low-configuration environments, data stored in config files, no database required | [①Docker Version](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②Source Code Deployment](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%8F%AA%E8%BF%90%E8%A1%8Cserver)| 2 cores 4GB if using `FunASR`, 2 cores 2GB if all APIs | - |
| **Full Module Installation** | Intelligent dialogue, IOT, MCP endpoints, voiceprint recognition, visual perception, OTA, intelligent control console | Complete functionality experience, data stored in database |[①Docker Version](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [②Source Code Deployment](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [③Source Code Deployment Auto-Update Tutorial](./docs/dev-ops-integration.md) | 4 cores 8GB if using `FunASR`, 2 cores 4GB if all APIs| [Local Source Code Startup Video Tutorial](https://www.bilibili.com/video/BV1wBJhz4Ewe) |
| **ARM64 Device Deployment** | Suitable for low-power ARM64 devices like Raspberry Pi, Jetson Nano | Lightweight deployment, ideal for development and small-scale use | [Docker ARM64 Deployment](./docs/docker-build.md) | Requires Raspberry Pi 4 with 8GB or higher | - |
> 💡 Note: Below is a test platform deployed with the latest code. You can burn and test if needed. Concurrent users: 6, data will be cleared daily.

137
docker-setup-arm.sh Normal file
View file

@ -0,0 +1,137 @@
#!/bin/bash
# Raspberry Pi ARM64 Setup Script for XiaoZhi Server (ESP32 Backend)
set -e # Exit immediately if any command fails
# ==== ARM64 Banner & Author ====
echo -e "\e[1;32m" # Bright green color
cat << "EOF"
Reference: VanillaNahida
Author: Huynh Tran
_ ____ __ __
/ \ | _ \ | \/ |
/ _ \ | |_) || |\/| |
/ ___ \| _ < | | | |
/_/ \_\_| \_\|_| |_|
EOF
echo -e "\e[0m" # Reset color
echo -e "\e[1;36m ARM64 Architecture Deployment Script - Author: Huynh Tran \e[0m\n"
sleep 1
# ==== End of Banner ====
# ========== 1. Create required directories ==========
BASE_DIR="/main/xiaozhi-server"
DATA_DIR="$BASE_DIR/data"
MODEL_DIR="$BASE_DIR/models/SenseVoiceSmall"
echo "📁 Checking and creating directory structure..."
[ -d "$DATA_DIR" ] && echo "✅ Data directory exists. Skipping..." || mkdir -p "$DATA_DIR"
[ -d "$MODEL_DIR" ] && echo "✅ Model directory exists. Skipping..." || mkdir -p "$MODEL_DIR"
# ========== 2. Download AI voice model ==========
MODEL_URL="https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt"
MODEL_PATH="$MODEL_DIR/model.pt"
if [ ! -f "$MODEL_PATH" ]; then
echo "📥 Downloading voice recognition model..."
curl -fL --progress-bar "$MODEL_URL" -o "$MODEL_PATH"
else
echo "✅ Model already downloaded at $MODEL_PATH. Skipping..."
fi
# ========== 3. Install Docker & buildx support ==========
if ! command -v docker >/dev/null 2>&1; then
echo "🐳 Docker not found. Installing Docker..."
curl -fsSL https://get.docker.com | sh
else
echo "✅ Docker already installed. Skipping..."
fi
# Enable buildx (if not already enabled)
if ! docker buildx ls >/dev/null 2>&1; then
echo "🔧 Enabling Docker buildx..."
docker buildx create --use
else
echo "✅ Buildx already enabled. Skipping..."
fi
# ========== 4. Build Docker Image for ARM64 ==========
IMAGE_NAME="xiaozhi-esp32-server:server-base"
if ! docker image inspect $IMAGE_NAME >/dev/null 2>&1; then
echo "🏗️ Building backend Docker image for ARM64..."
docker buildx build --no-cache --platform linux/arm64 \
-t $IMAGE_NAME \
-f ./Dockerfile-server-base \
.
else
echo "✅ Image $IMAGE_NAME already exists. Skipping build..."
fi
# ========== 5. Run Docker Compose (ARM64) ==========
COMPOSE_FILE="$(pwd)/main/xiaozhi-server/docker-compose_arm.yml"
if [ -f "$COMPOSE_FILE" ]; then
echo "🚀 Starting services with Docker Compose (ARM64)..."
docker compose -f "$COMPOSE_FILE" up -d --build
else
echo "❌ Docker Compose file not found at $COMPOSE_FILE"
exit 1
fi
# ========== 6. Prompt user for server.secret ==========
PUBLIC_IP=$(hostname -I | awk '{print $1}')
echo ""
echo "🔗 Server management panel addresses:"
echo " - Local: http://127.0.0.1:8002/"
echo " - Public: http://$PUBLIC_IP:8002/"
echo ""
echo "Open the above link in your browser and register the first admin account."
echo "Then log in → Go to 'More' → 'Parameter Management' → Find entry with Code: server.secret"
echo "Copy its value and paste it below."
echo ""
read -p "Please enter server.secret (leave blank to skip): " SECRET_KEY
# ========== 7. Write secret-key into config ==========
CONFIG_FILE="$DATA_DIR/.config.yaml"
if [ -n "$SECRET_KEY" ]; then
echo "🔑 Checking if pyyaml is installed..."
if ! python3 -c "import yaml" >/dev/null 2>&1; then
echo "⚠️ Module pyyaml not found. Installing with apt..."
sudo apt-get install -y python3-yaml
else
echo "✅ pyyaml is already installed."
fi
echo "🔑 Writing secret key into $CONFIG_FILE ..."
python3 - <<EOF
import yaml, os
config_path = "$CONFIG_FILE"
config = {}
if os.path.exists(config_path):
with open(config_path, "r") as f:
config = yaml.safe_load(f) or {}
config['manager-api'] = {
'url': 'http://xiaozhi-esp32-server-web:8002/xiaozhi',
'secret': '$SECRET_KEY'
}
with open(config_path, "w") as f:
yaml.dump(config, f, allow_unicode=True)
EOF
docker restart xiaozhi-esp32-server
echo "✅ Secret key added and container restarted."
else
echo "⚠️ No secret key provided. Skipping configuration update..."
fi
# ========== 8. Display summary ==========
LOCAL_IP=$(hostname -I | awk '{print $1}')
echo ""
echo "✅ Installation completed successfully!"
echo "---------------------------------------------"
echo "Admin Panel: http://$LOCAL_IP:8002"
echo "OTA Endpoint: http://$LOCAL_IP:8002/xiaozhi/ota/"
echo "Vision API: http://$LOCAL_IP:8003/mcp/vision/explain"
echo "WebSocket: ws://$LOCAL_IP:8000/xiaozhi/v1/"
echo "---------------------------------------------"
echo "🎉 Setup finished! You can now access the web dashboard."

View file

@ -1,12 +1,25 @@
# 本地编译docker镜像方法
现在本项目已经使用github自动编译docker功能,本文档是提供给有本地编译docker镜像需求的朋友准备的。
## 1、快速开始 (Quick Start)
下载源码(arm 分支
```
git clone -b arm https://github.com/HuYingTran/xiaozhi-esp32-server.git
```
```
cd xiaozhi-esp32-server
```
使用 root 权限执行自动化安装脚本(包括依赖、Docker 构建
```
sudo bash docker-setup-arm.sh
```
1、安装docker
## 2、现在本项目已经使用github自动编译docker功能,本文档是提供给有本地编译docker镜像需求的朋友准备的。
2.1、安装docker
```
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```
2、编译docker镜像
2.2、编译docker镜像
```
#进入项目根目录
# 编译server

View file

@ -0,0 +1,96 @@
# Docker安装全模块
version: '3'
services:
# Server模块
xiaozhi-esp32-server:
build:
context: ../..
dockerfile: Dockerfile-server-arm
container_name: xiaozhi-esp32-server
depends_on:
- xiaozhi-esp32-server-db
- xiaozhi-esp32-server-redis
restart: always
networks:
- default
ports:
# ws服务端
- "8000:8000"
# http服务的端口,用于视觉分析接口
- "8003:8003"
security_opt:
- seccomp:unconfined
environment:
- TZ=Asia/Shanghai
volumes:
# 配置文件目录
- ./data:/opt/xiaozhi-esp32-server/data
# 模型文件挂接,很重要
- ./models/SenseVoiceSmall/model.pt:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall/model.pt
# manager-api和manager-web模块
xiaozhi-esp32-server-web:
build:
context: ../..
dockerfile: Dockerfile-web
container_name: xiaozhi-esp32-server-web
restart: always
networks:
- default
depends_on:
xiaozhi-esp32-server-db:
condition: service_healthy
xiaozhi-esp32-server-redis:
condition: service_healthy
ports:
# 智控台
- "8002:8002"
environment:
- TZ=Asia/Shanghai
- SPRING_DATASOURCE_DRUID_URL=jdbc:mysql://xiaozhi-esp32-server-db:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&connectTimeout=30000&socketTimeout=30000&autoReconnect=true&failOverReadOnly=false&maxReconnects=10
- SPRING_DATASOURCE_DRUID_USERNAME=root
- SPRING_DATASOURCE_DRUID_PASSWORD=123456
- SPRING_DATA_REDIS_HOST=xiaozhi-esp32-server-redis
- SPRING_DATA_REDIS_PASSWORD=
- SPRING_DATA_REDIS_PORT=6379
volumes:
# 配置文件目录
- ./uploadfile:/uploadfile
# 数据库模块
xiaozhi-esp32-server-db:
image: mysql:latest
container_name: xiaozhi-esp32-server-db
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 45s
interval: 10s
retries: 10
restart: always
networks:
- default
expose:
- 3306
volumes:
- ./mysql/data:/var/lib/mysql
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=xiaozhi_esp32_server
- MYSQL_INITDB_ARGS="--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
# redis模块
xiaozhi-esp32-server-redis:
image: redis
expose:
- 6379
container_name: xiaozhi-esp32-server-redis
restart: always
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
networks:
- default
networks:
default: