-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.bat
More file actions
208 lines (183 loc) · 4.81 KB
/
docker.bat
File metadata and controls
208 lines (183 loc) · 4.81 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
@echo off
REM Script Manager Docker Helper for Windows
REM Provides easy commands for Docker Compose operations
setlocal enabledelayedexpansion
REM Get script directory
for %%i in ("%~dp0.") do set "SCRIPT_DIR=%%~fi"
cd /d "%SCRIPT_DIR%"
REM Check for help
if "%1"=="" goto show_help
if "%1"=="help" goto show_help
if "%1"=="-h" goto show_help
if "%1"=="--help" goto show_help
REM Check Docker installation
where docker >nul 2>nul
if errorlevel 1 (
echo Error: Docker is not installed
exit /b 1
)
where docker-compose >nul 2>nul
if errorlevel 1 (
echo Error: Docker Compose is not installed
exit /b 1
)
REM Command routing
if "%1"=="up" goto cmd_up
if "%1"=="down" goto cmd_down
if "%1"=="restart" goto cmd_restart
if "%1"=="build" goto cmd_build
if "%1"=="logs" goto cmd_logs
if "%1"=="logs-backend" goto cmd_logs_backend
if "%1"=="logs-frontend" goto cmd_logs_frontend
if "%1"=="shell-backend" goto cmd_shell_backend
if "%1"=="shell-frontend" goto cmd_shell_frontend
if "%1"=="status" goto cmd_status
if "%1"=="health" goto cmd_health
if "%1"=="clean" goto cmd_clean
if "%1"=="prod" goto cmd_prod
if "%1"=="prod-down" goto cmd_prod_down
if "%1"=="--compose" goto cmd_compose
echo Error: Unknown command: %1
echo.
goto show_help
:show_help
echo.
echo Script Manager Docker Helper
echo.
echo Usage:
echo docker.bat ^<command^> [options]
echo.
echo Commands:
echo up Start the application (development^)
echo down Stop the application
echo restart Restart the application
echo build Build Docker images
echo logs View application logs
echo logs-backend View backend logs only
echo logs-frontend View frontend logs only
echo shell-backend Access backend shell
echo shell-frontend Access frontend shell
echo clean Remove containers and volumes
echo status Show container status
echo health Check application health
echo prod Start with production config (includes Nginx^)
echo prod-down Stop production environment
echo.
echo Examples:
echo docker.bat up
echo docker.bat logs -f
echo docker.bat shell-backend
echo docker.bat prod
echo docker.bat down
echo.
exit /b 0
:cmd_up
echo Starting Script Manager (development^)...
docker-compose up -d
if errorlevel 1 goto error
echo.
echo Application started
echo Frontend: http://localhost:3000
echo Backend API: http://localhost:8000
echo API Docs: http://localhost:8000/docs
echo.
timeout /t 2 /nobreak
call :cmd_health
exit /b 0
:cmd_down
echo Stopping Script Manager...
docker-compose down
if errorlevel 1 goto error
echo Application stopped
exit /b 0
:cmd_restart
call :cmd_down
call :cmd_up
exit /b 0
:cmd_build
echo Building Docker images...
docker-compose build
if errorlevel 1 goto error
echo Images built successfully
exit /b 0
:cmd_logs
shift
docker-compose logs %*
exit /b %errorlevel%
:cmd_logs_backend
shift
docker-compose logs %* backend
exit /b %errorlevel%
:cmd_logs_frontend
shift
docker-compose logs %* frontend
exit /b %errorlevel%
:cmd_shell_backend
echo Accessing backend shell...
docker-compose exec backend bash
exit /b %errorlevel%
:cmd_shell_frontend
echo Accessing frontend shell...
docker-compose exec frontend sh
exit /b %errorlevel%
:cmd_status
echo Container status:
docker-compose ps
exit /b %errorlevel%
:cmd_health
echo Checking application health...
echo.
REM Check backend
for /f "tokens=*" %%i in ('curl -s http://localhost:8000/health 2^>nul') do set "response=%%i"
if defined response (
echo [OK] Backend is healthy (http://localhost:8000)
) else (
echo [!] Backend is starting... (check logs with 'docker.bat logs-backend')
)
REM Check frontend
for /f "tokens=*" %%i in ('curl -s http://localhost:3000 2^>nul') do set "response=%%i"
if defined response (
echo [OK] Frontend is healthy (http://localhost:3000)
) else (
echo [!] Frontend is starting... (check logs with 'docker.bat logs-frontend')
)
exit /b 0
:cmd_clean
setlocal
set /p confirm="This will remove containers and data volumes. Are you sure? (y/N) "
if /i not "%confirm%"=="y" (
echo Cleanup cancelled
exit /b 0
)
echo Cleaning up Docker resources...
docker-compose down -v
if errorlevel 1 goto error
echo Cleanup complete
exit /b 0
:cmd_prod
echo Starting Script Manager (production with Nginx^)...
docker-compose -f docker-compose.prod.yml up -d
if errorlevel 1 goto error
echo.
echo Application started
echo Frontend: http://localhost
echo API: http://localhost/api
echo.
timeout /t 2 /nobreak
call :cmd_health
exit /b 0
:cmd_prod_down
echo Stopping Script Manager (production^)...
docker-compose -f docker-compose.prod.yml down
if errorlevel 1 goto error
echo Application stopped
exit /b 0
:cmd_compose
setlocal enabledelayedexpansion
shift
docker-compose %*
exit /b %errorlevel%
:error
echo.
echo Error: Command failed with exit code !errorlevel!
exit /b 1