RAG/rebuild_and_start.sh

34 lines
1.1 KiB
Bash

#!/bin/bash
# 重新构建并启动 RAG 服务
set -e
echo "=== 停止所有容器 ==="
docker-compose down || true
# If a container with the name "rag-api" still exists (conflict), remove it forcefully
EXISTING=$(docker ps -a -q -f name=rag-api)
if [ -n "$EXISTING" ]; then
echo "=== 发现同名容器,正在强制删除 (container id: $EXISTING) ==="
docker rm -f "$EXISTING" || true
fi
# If a container with the name "rag-chromadb" still exists (conflict), remove it forcefully
EXISTING=$(docker ps -a -q -f name=rag-chromadb)
if [ -n "$EXISTING" ]; then
echo "=== 发现同名容器,正在强制删除 (container id: $EXISTING) ==="
docker rm -f "$EXISTING" || true
fi
# If a container with the name "rag-soffice" still exists (conflict), remove it forcefully
EXISTING=$(docker ps -a -q -f name=rag-soffice)
if [ -n "$EXISTING" ]; then
echo "=== 发现同名容器,正在强制删除 (container id: $EXISTING) ==="
docker rm -f "$EXISTING" || true
fi
echo "=== 重新构建镜像 ==="
docker-compose build --no-cache
echo "=== 启动服务 ==="
docker-compose up -d