-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathstart.bat
More file actions
108 lines (94 loc) · 3.03 KB
/
start.bat
File metadata and controls
108 lines (94 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
@echo off
setlocal enabledelayedexpansion
chcp 65001 >nul 2>&1
cd /d "%~dp0"
:: Enable ANSI colors
for /f %%a in ('echo prompt $E^| cmd') ^
do set "ESC=%%a"
set "GREEN=%ESC%[0;32m"
set "RED=%ESC%[0;31m"
set "YELLOW=%ESC%[1;33m"
set "CYAN=%ESC%[0;36m"
set "BOLD=%ESC%[1m"
set "DIM=%ESC%[2m"
set "NC=%ESC%[0m"
:: Docker check
docker info >nul 2>&1
if errorlevel 1 (
echo.
echo %YELLOW%[!!]%NC% Docker not running.
echo %DIM% -> %NC% Start Docker Desktop first.
exit /b 1
)
:: .env check
if not exist .env (
echo.
echo %RED%[!!]%NC% .env not found.
echo %DIM% -> %NC% Run setup.bat first.
exit /b 1
)
:: Banner
echo.
echo %CYAN%+===================================+%NC%
echo %CYAN%^|%NC% %BOLD%VoidAccess%NC% - Starting up %CYAN%^|%NC%
echo %CYAN%+===================================+%NC%
echo.
:: Detect compose file (absolute path)
set "COMPOSE_FILE=%~dp0infra\docker-compose.yml"
if not exist "%COMPOSE_FILE%" (
set "COMPOSE_FILE=%~dp0docker-compose.yml"
)
echo %DIM% -> %NC% Building and starting containers...
echo %DIM% (first run: 3-5 min, cached after)%NC%
echo.
:: Run docker compose - detached mode
:: --env-file uses absolute path so POSTGRES_PASSWORD, JWT_SECRET, etc.
:: always reach the containers regardless of cwd.
docker compose -f "%COMPOSE_FILE%" ^
--project-directory "%~dp0" ^
--env-file "%~dp0.env" ^
up --build -d
if errorlevel 1 (
echo %RED%[!!]%NC% Build/start failed.
echo %DIM% -> %NC% Run for details:
echo %DIM% docker compose -f "%COMPOSE_FILE%" --project-directory "%~dp0" --env-file "%~dp0.env" up --build%NC%
exit /b 1
)
echo %GREEN%[OK]%NC% Build complete
echo.
echo %DIM% -> %NC% Checking services...
echo.
:: Check each service
for %%S in (postgres tor fastapi nextjs) do (
set "HEALTHY=0"
set "ATTEMPTS=0"
:wait_%%S
set /a ATTEMPTS+=1
if !ATTEMPTS! gtr 30 goto timeout_%%S
for /f "tokens=*" %%H in ('docker inspect ^
--format "{{if .State.Health}}{{.State.Health.Status}}{{else}}running{{end}}" ^
voidaccess-%%S 2^>nul') do (
if "%%H"=="healthy" set "HEALTHY=1"
if "%%H"=="running" set "HEALTHY=1"
)
if "!HEALTHY!"=="1" (
echo %GREEN%[OK]%NC% %%S
goto done_%%S
)
timeout /t 3 /nobreak >nul
goto wait_%%S
:timeout_%%S
echo %YELLOW%[!!]%NC% %%S - slow to start
:done_%%S
)
echo.
echo %GREEN%+===================================+%NC%
echo %GREEN%^|%NC% %GREEN%^|%NC%
echo %GREEN%^|%NC% %GREEN%[OK]%NC% %BOLD%VoidAccess is ready!%NC% %GREEN%^|%NC%
echo %GREEN%^|%NC% %GREEN%^|%NC%
echo %GREEN%+===================================+%NC%
echo %GREEN%^|%NC% UI -> http://localhost:3001 %GREEN%^|%NC%
echo %GREEN%^|%NC% API -> http://localhost:8000 %GREEN%^|%NC%
echo %GREEN%+===================================+%NC%
echo.
endlocal