From ff8b1ccae70cbc36acb82ac023b148496e7c2adf Mon Sep 17 00:00:00 2001 From: HuYingTran Date: Fri, 14 Nov 2025 09:38:10 +0700 Subject: [PATCH 1/5] dev --- Dockerfile-server-arm | 6 ++ docker-setup-arm.sh | 116 +++++++++++++++++++++ main/xiaozhi-server/docker-compose_arm.yml | 96 +++++++++++++++++ 3 files changed, 218 insertions(+) create mode 100644 Dockerfile-server-arm create mode 100644 docker-setup-arm.sh create mode 100644 main/xiaozhi-server/docker-compose_arm.yml diff --git a/Dockerfile-server-arm b/Dockerfile-server-arm new file mode 100644 index 0000000000..3cc5686bec --- /dev/null +++ b/Dockerfile-server-arm @@ -0,0 +1,6 @@ +FROM xiaozhi-esp32-server:server-base + +WORKDIR /opt/xiaozhi-esp32-server +COPY main/xiaozhi-server . + +CMD ["python", "app.py"] \ No newline at end of file diff --git a/docker-setup-arm.sh b/docker-setup-arm.sh new file mode 100644 index 0000000000..cb609ea799 --- /dev/null +++ b/docker-setup-arm.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# Raspberry Pi ARM64 Setup Script for XiaoZhi Server (ESP32 Backend) + +set -e # Exit immediately if any command fails + +# ========== 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 + sudo usermod -aG docker $USER + newgrp docker +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 --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 'Parameter Dictionary' → '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 "🔑 Writing secret key into $CONFIG_FILE ..." + python3 - < Date: Fri, 14 Nov 2025 11:00:41 +0700 Subject: [PATCH 2/5] fix --- docker-setup-arm.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docker-setup-arm.sh b/docker-setup-arm.sh index cb609ea799..8758092751 100644 --- a/docker-setup-arm.sh +++ b/docker-setup-arm.sh @@ -3,6 +3,22 @@ set -e # Exit immediately if any command fails +# ==== ARM64 Banner & Author ==== +echo -e "\e[1;32m" # Bright green color +cat << "EOF" +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" @@ -27,8 +43,6 @@ fi if ! command -v docker >/dev/null 2>&1; then echo "🐳 Docker not found. Installing Docker..." curl -fsSL https://get.docker.com | sh - sudo usermod -aG docker $USER - newgrp docker else echo "✅ Docker already installed. Skipping..." fi @@ -72,7 +86,7 @@ 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 'Parameter Dictionary' → 'Parameter Management' → Find entry with Code: server.secret" +echo "Then log in → Go to 'More' → 'Parameter Management' → Find entry with Code: server.secret" echo "Copy its value and paste it below." echo "" From dbeb2f0b3f351104fdc1789ea70e35470d0cf389 Mon Sep 17 00:00:00 2001 From: HuYingTran Date: Fri, 14 Nov 2025 11:14:09 +0700 Subject: [PATCH 3/5] no cache --- docker-setup-arm.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-setup-arm.sh b/docker-setup-arm.sh index 8758092751..a76ed0de96 100644 --- a/docker-setup-arm.sh +++ b/docker-setup-arm.sh @@ -12,7 +12,6 @@ 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" @@ -59,7 +58,7 @@ fi 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 --platform linux/arm64 \ + docker buildx build --no-cache --platform linux/arm64 \ -t $IMAGE_NAME \ -f ./Dockerfile-server-base \ . From 1b9e7ead72a0b7ad4b75ea9bfc7e55a14b12400e Mon Sep 17 00:00:00 2001 From: HuYingTran Date: Fri, 14 Nov 2025 13:20:32 +0700 Subject: [PATCH 4/5] readme --- README.md | 1 + README_en.md | 1 + docker-setup-arm.sh | 8 ++++++++ docs/docker-build.md | 19 ++++++++++++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c8c39df7b8..921bd20266 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,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) diff --git a/README_en.md b/README_en.md index 015f105472..b35c42c614 100644 --- a/README_en.md +++ b/README_en.md @@ -188,6 +188,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. diff --git a/docker-setup-arm.sh b/docker-setup-arm.sh index a76ed0de96..5418e94600 100644 --- a/docker-setup-arm.sh +++ b/docker-setup-arm.sh @@ -6,6 +6,7 @@ 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 _ ____ __ __ / \ | _ \ | \/ | @@ -94,6 +95,13 @@ 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 now..." + python3 -m pip install --user pyyaml + else + echo "✅ pyyaml is already installed." + fi echo "🔑 Writing secret key into $CONFIG_FILE ..." python3 - < Date: Fri, 14 Nov 2025 13:30:03 +0700 Subject: [PATCH 5/5] fix yaml --- docker-setup-arm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-setup-arm.sh b/docker-setup-arm.sh index 5418e94600..61961cb898 100644 --- a/docker-setup-arm.sh +++ b/docker-setup-arm.sh @@ -97,8 +97,8 @@ 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 now..." - python3 -m pip install --user pyyaml + echo "⚠️ Module pyyaml not found. Installing with apt..." + sudo apt-get install -y python3-yaml else echo "✅ pyyaml is already installed." fi