@echo off title Document Translator V2 - Production Deploy cls echo ======================================== echo Document Translator V2 - Production Deploy echo ======================================== echo. REM Check Docker docker --version >nul 2>&1 if %ERRORLEVEL% neq 0 ( echo ERROR: Docker not found pause exit /b 1 ) REM Check files if not exist ".env.production" ( echo ERROR: .env.production not found pause exit /b 1 ) if not exist "api.txt" ( echo ERROR: api.txt not found pause exit /b 1 ) echo Files OK REM Stop containers echo Stopping containers... docker-compose -f docker-compose.prod.yml down --remove-orphans >nul 2>&1 REM Ask for cleanup set /p clean="Clean old images? (y/N): " if /i "%clean%"=="y" ( echo Cleaning... docker system prune -f >nul 2>&1 ) REM Build echo Building images... docker-compose -f docker-compose.prod.yml build --no-cache if %ERRORLEVEL% neq 0 ( echo ERROR: Build failed pause exit /b 1 ) REM Create dirs echo Creating directories... if not exist "uploads" mkdir uploads if not exist "cache" mkdir cache if not exist "logs" mkdir logs REM Start services echo Starting services... docker-compose -f docker-compose.prod.yml up -d if %ERRORLEVEL% neq 0 ( echo ERROR: Start failed pause exit /b 1 ) REM Wait echo Waiting... timeout /t 20 /nobreak >nul REM Init DB echo Initializing database... docker-compose -f docker-compose.prod.yml exec -T app python run_create_schema.py REM Final wait echo Final wait... timeout /t 30 /nobreak >nul REM Health check echo Checking health... set attempt=1 :healthcheck curl -s http://localhost:12010/api/health 2>nul | find "healthy" >nul if %ERRORLEVEL%==0 ( echo SUCCESS: App is healthy goto success ) if %attempt% geq 10 ( echo ERROR: Health check failed docker-compose -f docker-compose.prod.yml logs app pause exit /b 1 ) echo Retry %attempt%/10... timeout /t 10 /nobreak >nul set /a attempt+=1 goto healthcheck :success echo. echo ================================ echo DEPLOYMENT COMPLETED echo ================================ echo. echo URL: http://localhost:12010 echo Health: http://localhost:12010/api/health echo. echo Test Login: echo Email: ymirliu@panjit.com.tw echo Password: 3EDC4rfv5tgb echo. echo Status: docker-compose -f docker-compose.prod.yml ps echo. echo Commands: echo - Logs: docker-compose -f docker-compose.prod.yml logs -f app echo - Stop: docker-compose -f docker-compose.prod.yml down echo. pause