-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.ps1
79 lines (72 loc) · 2.37 KB
/
init.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Set strict mode
Set-StrictMode -Version Latest
$CHECKMARK_SYMBOL = @{
Object = [Char]8730
ForegroundColor = 'Green'
NoNewLine = $false
}
# Function to check command dependencies
function check_cmd_dep {
Param(
[string]$cmd
)
if ($cmd -eq "docker compose") {
$check_cmd = docker compose 2>$null
} else {
$check_cmd = Get-Command $cmd 2>$null
}
if ($check_cmd) {
Write-Host "$cmd " -NoNewLine
Write-Host @CHECKMARK_SYMBOL
return $true
} else {
Write-Host "$cmd "
Write-Host "X" -ForegroundColor Red
return $false
}
}
# Check required commands
Write-Host "Checking for requirements on this machine:" -ForegroundColor Yellow
$check_deps = $true
if (-not (check_cmd_dep "Invoke-WebRequest")) {
$check_deps = $false
}
if (-not (check_cmd_dep "docker")) {
$check_deps = $false
}
if (-not (check_cmd_dep "docker compose")) {
$check_deps = $false
}
if (-not (check_cmd_dep "mkdir")) {
$check_deps = $false
}
if (-not (check_cmd_dep "Get-Location")) {
$check_deps = $false
}
if (-not $check_deps) {
Write-Host "All requirements must be satisfied to run this script!" -ForegroundColor Red
exit 1
}
$DIR = Get-Location
$MGPLAT_DIR = "$DIR\memgraph-platform"
$MGPLAT_COMPOSE_PATH = "$MGPLAT_DIR\docker-compose.yml"
$DOCKER_COMPOSE_URL = "https://raw.githubusercontent.com/memgraph/memgraph-platform/main/docker-compose.yml"
# Check if compose file already exists
if (Test-Path $MGPLAT_COMPOSE_PATH) {
Write-Host "Overwriting docker compose file found at: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow
} elseif (-not (Test-Path $MGPLAT_DIR)) {
New-Item -ItemType Directory -Path $MGPLAT_DIR | Out-Null
}
# Download compose file
Write-Host "Downloading docker compose file to: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow
Invoke-WebRequest -Uri $DOCKER_COMPOSE_URL -OutFile "$MGPLAT_COMPOSE_PATH"
if (-not $?) {
Write-Host "Something went wrong when downloading docker-compose.yml from $DOCKER_COMPOSE_URL" -ForegroundColor Red
}
# Run compose
Set-Location $MGPLAT_DIR
Write-Host "Pulling memgraph/lab:latest and memgraph/memgraph-mage:latest" -ForegroundColor Yellow
docker pull memgraph/lab:latest
docker pull memgraph/memgraph-mage:latest
Write-Host "Spinning up memgraph lab and memgraph with mage using docker compose file from: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow
docker compose up