chatdesk-ui/b.sh

42 lines
1.0 KiB
Bash
Executable File

#!/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."