-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
43 lines (37 loc) · 1.21 KB
/
Copy pathrun.bat
File metadata and controls
43 lines (37 loc) · 1.21 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
@echo off
REM SocketLab – Docker Compose helper (CMD)
REM Usage:
REM run.bat -> default example (01_hello_server)
REM run.bat 02_echo_server_blocking -> interactive echo example
REM run.bat 02_echo_server_blocking down -> stop containers
REM
REM Interactive examples (e.g. echo) start the server in the background and
REM attach the client with a live stdin so you can type messages.
SET EXAMPLE=%~1
IF "%EXAMPLE%"=="" SET EXAMPLE=01_hello_server
SET ACTION=%~2
IF "%ACTION%"=="" SET ACTION=up
IF /I "%ACTION%"=="down" (
docker compose down
GOTO :EOF
)
IF /I "%ACTION%"=="up" (
IF "%EXAMPLE%"=="02_echo_server_blocking" GOTO :interactive
IF "%EXAMPLE%"=="03_echo_server_fork" GOTO :interactive
docker compose up --build
GOTO :EOF
)
:interactive
echo Building images...
docker compose build
echo Starting server in background...
docker compose up -d server
echo Waiting for server DNS to register...
timeout /t 2 /nobreak >nul
echo Attaching interactive client ^(type messages, empty line to quit^)...
docker compose run --no-deps --rm client
echo Tearing down...
docker compose down
GOTO :EOF
echo Unknown action "%ACTION%". Use "up" or "down".
exit /b 1