-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathstart.bat
More file actions
243 lines (219 loc) · 7.16 KB
/
Copy pathstart.bat
File metadata and controls
243 lines (219 loc) · 7.16 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
@echo off
REM =============================================================================
REM GigaChad GRC - One-Command Start (Windows)
REM =============================================================================
REM
REM USAGE:
REM start.bat Start all services
REM start.bat stop Stop all services
REM start.bat logs View logs
REM start.bat status Check service status
REM
REM REQUIREMENTS:
REM - Docker Desktop installed and running
REM
REM =============================================================================
setlocal enabledelayedexpansion
REM Colors (limited in Windows CMD)
set "GREEN=[92m"
set "YELLOW=[93m"
set "BLUE=[94m"
set "CYAN=[96m"
set "RED=[91m"
set "NC=[0m"
REM Get script directory
cd /d "%~dp0"
if "%1"=="" goto start
if "%1"=="start" goto start
if "%1"=="stop" goto stop
if "%1"=="logs" goto logs
if "%1"=="status" goto status
if "%1"=="reset" goto reset
goto usage
:banner
echo.
echo %CYAN%===============================================================%NC%
echo %CYAN% %NC%
echo %CYAN% GigaChad GRC %NC%
echo %CYAN% %NC%
echo %CYAN%===============================================================%NC%
echo.
goto :eof
:check_docker
where docker >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%ERROR: Docker is not installed.%NC%
echo.
echo Please install Docker Desktop:
echo https://www.docker.com/products/docker-desktop
echo.
exit /b 1
)
docker info >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%ERROR: Docker is not running.%NC%
echo.
echo Please start Docker Desktop and try again.
echo.
exit /b 1
)
goto :eof
:setup_env
REM Check if .env exists
if exist ".env" (
echo %GREEN%Using existing .env file%NC%
goto :eof
)
echo %YELLOW%No .env file found - generating secure secrets...%NC%
REM Generate secrets using PowerShell
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToHexString([Security.Cryptography.RandomNumberGenerator]::GetBytes(32)).ToLower()"') do set ENCRYPTION_KEY=%%a
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(48))"') do set JWT_SECRET=%%a
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(48))"') do set SESSION_SECRET=%%a
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(24)) -replace '\+','-' -replace '/','_'"') do set POSTGRES_PASSWORD=%%a
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(24)) -replace '\+','-' -replace '/','_'"') do set REDIS_PASSWORD=%%a
for /f "delims=" %%a in ('powershell -Command "[Convert]::ToBase64String([Security.Cryptography.RandomNumberGenerator]::GetBytes(20)) -replace '\+','-' -replace '/','_'"') do set MINIO_PASSWORD=%%a
REM Create .env file
(
echo # ============================================================================
echo # GigaChad GRC - Environment Configuration
echo # Generated by start.bat
echo # ============================================================================
echo.
echo NODE_ENV=development
echo.
echo # Security Secrets ^(auto-generated^)
echo ENCRYPTION_KEY=%ENCRYPTION_KEY%
echo JWT_SECRET=%JWT_SECRET%
echo SESSION_SECRET=%SESSION_SECRET%
echo.
echo # Database
echo POSTGRES_USER=grc
echo POSTGRES_PASSWORD=%POSTGRES_PASSWORD%
echo POSTGRES_DB=gigachad_grc
echo DATABASE_URL=postgresql://grc:%POSTGRES_PASSWORD%@localhost:5433/gigachad_grc
echo.
echo # Redis
echo REDIS_PASSWORD=%REDIS_PASSWORD%
echo REDIS_URL=redis://:%REDIS_PASSWORD%@localhost:6380
echo.
echo # RustFS ^(S3-Compatible Object Storage^)
echo MINIO_ROOT_USER=rustfsadmin
echo MINIO_ROOT_PASSWORD=%MINIO_PASSWORD%
echo MINIO_ENDPOINT=localhost
echo MINIO_PORT=9000
echo.
echo # Authentication
echo KEYCLOAK_ADMIN=admin
echo KEYCLOAK_ADMIN_PASSWORD=admin
echo KEYCLOAK_REALM=gigachad-grc
echo USE_DEV_AUTH=true
echo.
echo # CORS
echo CORS_ORIGINS=http://localhost:3000,http://localhost:5173,http://localhost:5174
echo.
echo # Rate Limiting
echo RATE_LIMIT_ENABLED=true
echo RATE_LIMIT_WINDOW_MS=60000
echo RATE_LIMIT_MAX_REQUESTS=1000
echo.
echo # Logging
echo LOG_LEVEL=debug
echo.
echo # Frontend
echo VITE_API_URL=http://localhost:3001
echo VITE_ENABLE_DEV_AUTH=true
echo VITE_ENABLE_AI_MODULE=true
) > .env
echo %GREEN%Created .env with secure secrets%NC%
goto :eof
:start
call :banner
call :check_docker
call :setup_env
echo.
echo %BLUE%Starting GigaChad GRC...%NC%
echo.
echo This may take a few minutes on first run while Docker builds the images.
echo.
docker compose up -d --build
echo.
echo %GREEN%===============================================================%NC%
echo %GREEN% %NC%
echo %GREEN% GigaChad GRC is Starting! %NC%
echo %GREEN% %NC%
echo %GREEN%===============================================================%NC%
echo.
echo Access Points:
echo Frontend http://localhost:3000
echo API Docs http://localhost:3001/api/docs
echo Keycloak http://localhost:8080 (admin/admin)
echo Grafana http://localhost:3003 (admin/admin)
echo.
echo How to Login:
echo 1. Go to http://localhost:3000
echo 2. Click the "Dev Login" button
echo 3. You're in! No password needed.
echo.
echo %YELLOW%Note:%NC% First startup takes 2-3 minutes for database initialization.
echo.
echo Commands:
echo start.bat stop Stop all services
echo start.bat logs View logs
echo start.bat status Check service status
echo.
REM Open browser after delay
echo %YELLOW%Opening browser in 10 seconds...%NC%
timeout /t 10 /nobreak >nul
start http://localhost:3000
goto :eof
:stop
call :banner
echo %YELLOW%Stopping GigaChad GRC...%NC%
docker compose down
echo %GREEN%All services stopped%NC%
echo.
goto :eof
:logs
docker compose logs -f
goto :eof
:status
call :banner
echo Service Status:
echo.
docker compose ps
echo.
goto :eof
:reset
call :banner
echo %RED%WARNING: This will delete ALL data including:%NC%
echo - Database (all users, controls, frameworks, etc.)
echo - Redis cache
echo - Uploaded files
echo - Configuration in .env
echo.
set /p CONFIRM="Are you sure you want to reset everything? (y/N) "
if /i "%CONFIRM%"=="y" (
echo %YELLOW%Stopping all services and removing volumes...%NC%
docker compose down -v
if exist ".env" (
echo %YELLOW%Removing .env file...%NC%
del /f .env
)
echo %GREEN%Reset complete%NC%
echo.
echo Run start.bat to start fresh with new credentials.
echo.
) else (
echo %YELLOW%Reset cancelled%NC%
)
goto :eof
:usage
echo Usage: start.bat [start^|stop^|logs^|status^|reset]
echo.
echo Commands:
echo start Start all services (default)
echo stop Stop all services
echo logs View service logs
echo status Check service status
echo reset Delete all data and start fresh (fixes auth issues)
exit /b 1