改用API驗證

This commit is contained in:
beabigegg
2025-10-02 17:13:24 +08:00
parent 0a89c19fc9
commit adecdf0cce
48 changed files with 6136 additions and 1239 deletions

122
deploy-production.bat Normal file
View File

@@ -0,0 +1,122 @@
@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