-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-run.ps1
More file actions
113 lines (102 loc) · 3.92 KB
/
docker-run.ps1
File metadata and controls
113 lines (102 loc) · 3.92 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# PowerShell script for running SOKEGraph in Docker on Windows
Write-Host ""
Write-Host "SOKEGraph Docker Setup" -ForegroundColor Blue
Write-Host ""
# Create necessary directories on host
Write-Host "Creating data directories..." -ForegroundColor Yellow
New-Item -ItemType Directory -Force -Path "data/uploads", "data/outputs", "data/logs", "external/output" | Out-Null
# Check if .env exists
if (-not (Test-Path ".env")) {
Write-Host "No .env found." -ForegroundColor Yellow
if (Test-Path ".env.example") {
Write-Host "Creating .env from .env.example..." -ForegroundColor Yellow
Copy-Item ".env.example" ".env"
Write-Host "[OK] .env created from template." -ForegroundColor Green
} else {
Write-Host "[WARNING] No .env.example found. Creating a blank .env file..." -ForegroundColor Yellow
New-Item -ItemType File -Path ".env" -Force | Out-Null
Write-Host "[OK] Blank .env created." -ForegroundColor Green
}
}
# Detect docker compose command (V2 vs V1)
Write-Host ""
$dockerComposeCmd = $null
try {
$null = docker compose version 2>&1
if ($LASTEXITCODE -eq 0) {
$dockerComposeCmd = "docker", "compose"
Write-Host "Using Docker Compose V2 (docker compose)" -ForegroundColor Cyan
}
} catch {
# Docker Compose V2 not available
}
if (-not $dockerComposeCmd) {
try {
$null = docker-compose version 2>&1
if ($LASTEXITCODE -eq 0) {
$dockerComposeCmd = "docker-compose"
Write-Host "Using Docker Compose V1 (docker-compose)" -ForegroundColor Cyan
}
} catch {
Write-Host "[ERROR] Neither 'docker compose' nor 'docker-compose' found." -ForegroundColor Red
Write-Host "Please install Docker Desktop or Docker Compose." -ForegroundColor Yellow
exit 1
}
}
if (-not $dockerComposeCmd) {
Write-Host "[ERROR] Neither 'docker compose' nor 'docker-compose' found." -ForegroundColor Red
Write-Host "Please install Docker Desktop or Docker Compose." -ForegroundColor Yellow
exit 1
}
# Build and run
Write-Host ""
Write-Host "Building Docker image..." -ForegroundColor Yellow
if ($dockerComposeCmd -is [array]) {
& $dockerComposeCmd[0] $dockerComposeCmd[1] build
} else {
& $dockerComposeCmd build
}
Write-Host ""
Write-Host "Starting SOKEGraph application..." -ForegroundColor Yellow
if ($dockerComposeCmd -is [array]) {
& $dockerComposeCmd[0] $dockerComposeCmd[1] up -d
} else {
& $dockerComposeCmd up -d
}
# Wait for service to be ready
Write-Host ""
Write-Host "Waiting for application to start..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
# Check if container is running
$container = docker ps -q -f name=sokegraph-streamlit
if ($container) {
Write-Host ""
Write-Host "[SUCCESS] SOKEGraph is running!" -ForegroundColor Green
Write-Host ""
Write-Host "Access the application at: " -NoNewline -ForegroundColor Blue
Write-Host "http://localhost:8501" -ForegroundColor Cyan
Write-Host ""
Write-Host "Your output files will be available in:" -ForegroundColor Blue
Write-Host " - ./data/outputs/ (ranking results, graphs)"
Write-Host " - ./external/output/ (pipeline outputs)"
Write-Host " - ./data/logs/ (application logs)"
Write-Host ""
Write-Host "Useful commands:" -ForegroundColor Blue
if ($dockerComposeCmd -is [array]) {
$cmdStr = "$($dockerComposeCmd[0]) $($dockerComposeCmd[1])"
} else {
$cmdStr = $dockerComposeCmd
}
Write-Host " View logs: $cmdStr logs -f"
Write-Host " Stop: $cmdStr down"
Write-Host " Restart: $cmdStr restart"
Write-Host " Shell access: docker exec -it sokegraph-streamlit bash"
} else {
Write-Host ""
Write-Host "[WARNING] Container failed to start. Check logs:" -ForegroundColor Yellow
if ($dockerComposeCmd -is [array]) {
& $dockerComposeCmd[0] $dockerComposeCmd[1] logs
} else {
& $dockerComposeCmd logs
}
}