-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
42 lines (38 loc) · 1.42 KB
/
Copy pathrun.ps1
File metadata and controls
42 lines (38 loc) · 1.42 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
# SocketLab – Docker Compose helper (PowerShell)
# Usage:
# .\run.ps1 # default example (01_hello_server)
# .\run.ps1 02_echo_server_blocking # interactive echo example
# .\run.ps1 01_hello_server down # stop containers
#
# Interactive examples (e.g. echo) start the server in the background and
# attach the client with a live stdin so you can type messages.
param(
[string]$Example = "01_hello_server",
[string]$Action = "up"
)
$env:EXAMPLE = $Example
# Examples that need interactive stdin on the client side
$interactiveExamples = @("02_echo_server_blocking", "03_echo_server_fork")
switch ($Action) {
"up" {
if ($interactiveExamples -contains $Example) {
Write-Host "Building images..."
docker compose build
Write-Host "Starting server in background..."
docker compose up -d server
Write-Host "Waiting for server DNS to register..."
Start-Sleep -Seconds 2
Write-Host "Attaching interactive client (type messages, empty line to quit)..."
docker compose run --no-deps --rm client
Write-Host "Tearing down..."
docker compose down
} else {
docker compose up --build
}
}
"down" { docker compose down }
default {
Write-Error "Unknown action '$Action'. Use 'up' or 'down'."
exit 1
}
}