@echo off setlocal EnableDelayedExpansion rem keep window open when double-clicked set "SELF=%~f0" if /i not "%~1"=="__run__" ( echo %CMDCMDLINE% | find /i " /c " >nul if not errorlevel 1 ( cmd /k "%SELF%" __run__ exit /b ) ) set "ROOT=%~dp0.." for %%I in ("%ROOT%") do set "ROOT=%%~fI" cd /d "%ROOT%" || ( echo [ERROR] Cannot cd to project root: %ROOT% exit /b 1 ) set "COMPOSE=docker\docker-compose.yml" set "ENV_FILE=docker\.env" set "PROJECT=soondesign" set "WEB_PORT=8100" set "ELECTRON_PORT=8101" set "BACKEND_PORT=8102" echo [SoonDesign] Local dev stack echo. docker info >nul 2>&1 if errorlevel 1 ( echo [ERROR] Docker Desktop is not running. exit /b 1 ) if not exist "%ROOT%\docker\docker-compose.yml" ( echo [ERROR] Missing docker\docker-compose.yml exit /b 1 ) if not exist "%ROOT%\soonModels\" mkdir "%ROOT%\soonModels" if not exist "%ENV_FILE%" ( if not exist "docker\.env.example" ( echo [ERROR] Missing docker\.env.example exit /b 1 ) copy /Y "docker\.env.example" "%ENV_FILE%" >nul ) powershell -NoProfile -ExecutionPolicy Bypass -File "docker\sync-config.ps1" -EnvFile "%ENV_FILE%" if errorlevel 1 ( echo [ERROR] Config sync failed. exit /b 1 ) for /f "usebackq eol=# tokens=1,* delims==" %%A in ("%ENV_FILE%") do ( if /i "%%A"=="WEB_PORT" set "WEB_PORT=%%B" if /i "%%A"=="ELECTRON_PORT" set "ELECTRON_PORT=%%B" if /i "%%A"=="BACKEND_PORT" set "BACKEND_PORT=%%B" ) echo [INFO] Ports Web=%WEB_PORT% Electron=%ELECTRON_PORT% API=%BACKEND_PORT% docker image inspect soondesign-api:dev >nul 2>&1 if errorlevel 1 ( echo [INFO] First run: building API image with pdo_mysql... docker compose -p "%PROJECT%" -f "%COMPOSE%" --env-file "%ENV_FILE%" up -d --build ) else ( docker compose -p "%PROJECT%" -f "%COMPOSE%" --env-file "%ENV_FILE%" up -d ) if errorlevel 1 ( echo [ERROR] docker compose up failed. exit /b 1 ) echo [INFO] Waiting for API http://localhost:%BACKEND_PORT%/health ... set /a RETRY=0 :L_wait set /a RETRY+=1 curl.exe -sf "http://localhost:%BACKEND_PORT%/health" >nul 2>&1 if not errorlevel 1 goto L_ok if !RETRY! GEQ 60 ( echo [WARN] API not ready. Check: docker logs soondesign-api goto L_urls ) set /a MOD=!RETRY! %% 5 if !MOD!==0 echo ... waiting !RETRY!/60 ping -n 3 127.0.0.1 >nul goto L_wait :L_ok echo [OK] API ready. :L_urls echo. echo ======================================== echo Web: http://localhost:%WEB_PORT%/pages/index.web.html echo Admin: http://localhost:%WEB_PORT%/pages/admin/index.html echo Electron: http://localhost:%ELECTRON_PORT%/pages/index.html echo API: http://localhost:%BACKEND_PORT%/health echo ======================================== echo Login: admin@local.test / admin123 echo Desktop: cd frontend-electron ^&^& npm start echo Stop: docker compose -p %PROJECT% -f docker\docker-compose.yml down echo. echo [DONE] Edit frontend-web/backend-web files and refresh browser to debug. exit /b 0