-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ps1
More file actions
49 lines (40 loc) · 1.58 KB
/
Copy pathrun.ps1
File metadata and controls
49 lines (40 loc) · 1.58 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
<#
Thin convenience wrapper around the docker compose invocations used in this
repo, so you don't need to remember the multi-file flags. Everything here
is optional - a plain `docker compose -f ... up -d` works exactly the same.
Equivalent to run.sh, for Windows users not using Git Bash.
Usage:
.\run.ps1 dev {up|down|restart|logs [service]|ps} local dev stack (inbucket mail, fresh db)
.\run.ps1 prod {up|down|restart|logs [service]|ps} production stack (no dev overrides)
.\run.ps1 reset wipe everything and start over (see reset.ps1)
#>
param(
[Parameter(Position = 0)] [string]$EnvName,
[Parameter(Position = 1)] [string]$Action,
[Parameter(ValueFromRemainingArguments = $true)] [string[]]$Rest
)
Set-Location $PSScriptRoot
function Show-Usage {
Write-Host "Usage: .\run.ps1 {dev|prod} {up|down|restart|logs [service]|ps}"
Write-Host " or: .\run.ps1 reset"
exit 1
}
if (-not $EnvName) { Show-Usage }
if ($EnvName -eq 'reset') {
& "$PSScriptRoot\reset.ps1"
exit $LASTEXITCODE
}
switch ($EnvName) {
'dev' { $files = @('-f', 'docker-compose.yml', '-f', './dev/docker-compose.dev.yml') }
'prod' { $files = @('-f', 'docker-compose.yml') }
default { Show-Usage }
}
if (-not $Action) { Show-Usage }
switch ($Action) {
'up' { docker compose @files up -d @Rest }
'down' { docker compose @files down @Rest }
'restart' { docker compose @files restart @Rest }
'logs' { docker compose @files logs -f @Rest }
'ps' { docker compose @files ps @Rest }
default { Show-Usage }
}