-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-update-lobe-chat.sh
43 lines (34 loc) · 1.38 KB
/
auto-update-lobe-chat.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# auto-update-lobe-chat.sh
# 设置代理(可选)
# export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
# 拉取最新的镜像并将输出存储在变量中
# echo "pulling Lobe-Chat"
# output=$(docker pull lobehub/lobe-chat:latest 2>&1)
# echo "$output"
# # 检查拉取命令是否成功执行
# if [ $? -ne 0 ]; then
# exit 1
# fi
# # 检查输出中是否包含特定的字符串
# echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
# # 如果镜像已经是最新的,则不执行任何操作
# if [ $? -eq 0 ]; then
# exit 0
# fi
# echo "Detected Lobe-Chat update"
# 执行Dockerfile
echo "Building Lobe-Chat"
docker build -t lobehub/lobe-chat:sd .
# 停止旧的容器
echo "Stopped: $(docker stop Lobe-Chat)"
# 删除旧的容器
echo "Removed: $(docker rm -f Lobe-Chat)"
# 运行新的容器
echo "Started: $(docker run -p 3210:3210 -d --network=host --env-file ./lobe.env --name=Lobe-Chat --restart=always lobehub/lobe-chat:sd)"
# 打印更新的时间和版本
echo "Update time: $(date)"
echo "Version: $(docker inspect lobehub/lobe-chat:sd | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
# 清理不再使用的镜像
# docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
# echo "Removed old images."