@echo off
setlocal enabledelayedexpansion

REM 检查Docker是否正在运行
docker info >nul 2>&1
if %errorlevel% neq 0 (
    echo Docker is not running. Please start Docker and try again.
    pause
    exit /b 1
)

REM 检查容器是否存在
docker ps -a | findstr "qy_lty" >nul
if %errorlevel% equ 0 (
    echo Container qy_lty exists. Stopping and removing...
    docker stop qy_lty
    docker rm qy_lty
)

REM 构建并启动容器
echo Building and starting container...
docker-compose up -d --build

REM 等待容器启动
timeout /t 5

REM 检查容器是否正在运行
docker ps | findstr "qy_lty" >nul
if %errorlevel% equ 0 (
    echo Container qy_lty is running successfully.
) else (
    echo Failed to start container qy_lty.
)

pause 