-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.ps1
executable file
·58 lines (48 loc) · 1.29 KB
/
dev.ps1
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
#!/usr/bin/env pwsh
$initialLocation = (Get-Location).Path
function Exit-Script {
param ($code, $message)
if ($message) {
Write-Host $message
}
Set-Location "$initialLocation"
Exit $code
}
if (!($IsWindows)) {
Exit-Script 0 "Please use the Bash script 'dev' instead."
}
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$arch = "arm64"
$dotnetArch = "arm64"
} else {
$arch = "amd64"
$dotnetArch = "x64"
}
$workspace = $PSScriptRoot
$dockerfile = "Dockerfile"
$dockerImg = "etscript/dev:r1.73-n8.0"
Set-Location $workspace
Get-Command docker *> $null
if (!($?)) {
Exit-Script 1 "Error: could not find the 'docker' command."
}
if (!(Test-Path "$workspace/$dockerfile" -PathType Leaf)) {
Exit-Script 1 "Error: could not find '$dockerfile'."
}
docker image inspect $dockerImg *> $null
if (!($?)) {
Write-Host "Using '$dockerfile' to build an image..."
docker buildx build `
--platform linux/$arch `
--build-arg dotnet_arch=$dotnetArch `
-t $dockerImg `
-f "$workspace/$dockerfile" `
"$workspace"
}
docker run -it --init --rm `
-u etscript:etscript `
--mount "type=bind,source=$workspace,target=/workspace" `
-w /workspace `
--cap-add SYS_PTRACE `
--security-opt seccomp=unconfined `
$dockerImg