-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-monster.ps1
More file actions
executable file
·75 lines (65 loc) · 2.78 KB
/
start-monster.ps1
File metadata and controls
executable file
·75 lines (65 loc) · 2.78 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
# PowerShell script to start the .NET DevBench Monster Container
# For Windows users who want to run from PowerShell
Write-Host "🚀 Starting the .NET DevBench Monster Container" -ForegroundColor Green
# Check if we're in WSL context or need to use WSL
if ($env:WSL_DISTRO_NAME) {
# We're already in WSL
Write-Host " Running in WSL: $env:WSL_DISTRO_NAME" -ForegroundColor Cyan
# Get user info using bash
$userInfo = bash -c 'echo "$(whoami):$(id -u):$(id -g)"'
$parts = $userInfo.Split(':')
$env:USER = $parts[0]
$env:UID = $parts[1]
$env:GID = $parts[2]
} else {
# We're in Windows PowerShell, need to use WSL
Write-Host " Using WSL to get user info..." -ForegroundColor Cyan
try {
$userInfo = wsl bash -c 'echo "$(whoami):$(id -u):$(id -g)"'
$parts = $userInfo.Split(':')
$env:USER = $parts[0]
$env:UID = $parts[1]
$env:GID = $parts[2]
} catch {
Write-Host "❌ Error: Could not get user info from WSL" -ForegroundColor Red
Write-Host " Make sure WSL is installed and working" -ForegroundColor Yellow
exit 1
}
}
Write-Host " User: $env:USER (UID: $env:UID, GID: $env:GID)" -ForegroundColor Cyan
# Validate we have the required info
if (-not $env:USER -or -not $env:UID -or -not $env:GID) {
Write-Host "❌ Error: Could not determine user info" -ForegroundColor Red
Write-Host " USER=$env:USER, UID=$env:UID, GID=$env:GID" -ForegroundColor Yellow
exit 1
}
Write-Host "🔧 Building container with user mapping..." -ForegroundColor Yellow
# Change to the correct directory
Push-Location -Path ".devcontainer"
try {
# Start the container with proper user mapping
if ($env:WSL_DISTRO_NAME) {
# Already in WSL
& docker-compose up -d --build
} else {
# Use WSL to run docker-compose
& wsl docker-compose up -d --build
}
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Container started successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "🎯 Next steps:" -ForegroundColor Cyan
Write-Host " - Open VS Code and select 'Reopen in Container'" -ForegroundColor White
Write-Host " - Or run: docker exec -it dot_net_bench zsh" -ForegroundColor White
Write-Host ""
Write-Host "🔍 To check container status:" -ForegroundColor Cyan
Write-Host " docker ps | grep dot_net_bench" -ForegroundColor White
} else {
Write-Host "❌ Container failed to start. Check Docker logs:" -ForegroundColor Red
Write-Host " docker-compose logs" -ForegroundColor Yellow
}
} catch {
Write-Host "❌ Error running docker-compose: $_" -ForegroundColor Red
} finally {
Pop-Location
}