From c37ce1dac50940b4a21e1a33877d71bc2a8d4df0 Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 18 Jul 2025 22:29:18 +0800 Subject: [PATCH] b.sh --- b.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 b.sh diff --git a/b.sh b/b.sh new file mode 100755 index 0000000..cf3a0ba --- /dev/null +++ b/b.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# 设置变量 +REPO_NAME="chatdesk-ui" +TAG="1.0.0" +IMAGE_NAME="chatdesk-ui:$TAG" +CONTAINER_NAME="chatdesk-ui" + +# 停止并删除旧的容器实例 +echo "Stopping and removing any running containers of $REPO_NAME:$TAG..." +docker ps -q --filter "ancestor=$REPO_NAME:$TAG" | xargs -r docker stop +docker ps -a -q --filter "ancestor=$REPO_NAME:$TAG" | xargs -r docker rm + +# 删除镜像 +echo "Removing image $REPO_NAME:$TAG..." +docker rmi $IMAGE_NAME + +# 执行 git pull 获取最新代码 +echo "Pulling the latest code from the repository..." +git pull + +# 重建 Docker 镜像 +echo "Building the Docker image $IMAGE_NAME..." +docker build \ + --build-arg http_proxy=http://127.0.0.1:7890 \ + --build-arg https_proxy=http://127.0.0.1:7890 \ + --network=host \ + --no-cache \ + -t $IMAGE_NAME . + +# 运行新镜像 +echo "Running the container with the new image..." +docker run -d \ + -e SUPABASE_URL=http://67.223.119.33:8000 \ + -p 3030:3030 \ + -p 8000:8000 \ + --name $CONTAINER_NAME \ + $IMAGE_NAME + +echo "Deployment complete." +