ai-lightrag/deploy.sh

36 lines
938 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 定义变量
IMAGE_NAME="lightrag-service"
CONTAINER_NAME="lightrag-container"
PORT=9600
DATA_DIR="$(pwd)/index_data"
# 确保数据目录存在
mkdir -p "$DATA_DIR"
# 1. 构建镜像
echo "正在构建 Docker 镜像..."
docker build -t $IMAGE_NAME .
# 2. 停止旧容器
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
echo "停止并删除旧容器..."
docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
fi
# 3. 启动新容器
echo "启动服务..."
# 注意:如果是 Linux/WSL访问宿主机网络可能需要 --network host 或者特殊配置
# 这里假设 Ollama 是在宿主机 192.168.6.109 上,容器内可以直接访问该 IP
docker run -d \
--name $CONTAINER_NAME \
-p $PORT:$PORT \
-v "$DATA_DIR":/app/index_data \
--restart unless-stopped \
$IMAGE_NAME
echo "服务已启动: http://localhost:$PORT"
echo "查看日志: docker logs -f $CONTAINER_NAME"