forked from Sitecore/Sitecore.Demo.Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup.ps1
70 lines (62 loc) · 2.4 KB
/
up.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
# DEMO TEAM CUSTOMIZATION - Add ability to skip building the containers.
[CmdletBinding(DefaultParameterSetName = "no-arguments")]
Param (
[Parameter(HelpMessage = "Whether to skip building the Docker images.")]
[switch]$SkipBuild,
[Parameter(HelpMessage = "Whether to set up the environment with pre-release version of Sitecore products (internal only) .")]
[switch]$PreRelease
)
$ErrorActionPreference = "Stop";
# Double check whether init has been run
$envCheckVariable = "REPORTING_API_KEY"
$envCheck = Get-Content .env -Encoding UTF8 | Where-Object { $_ -imatch "^$envCheckVariable=.+" }
if (-not $envCheck) {
# DEMO TEAM CUSTOMIZATION - Auto run init.ps1 if not run.
if (Test-Path "C:\License") {
Write-Host "Initializing environment using default values" -ForegroundColor Yellow
& .\init.ps1 -InitEnv -AdminPassword b -LicenseXmlPath C:\License\license.xml
if ($PreRelease) {
& .\init-ci.ps1 -PreRelease
}
else {
& .\init-ci.ps1
}
}
else {
throw "$envCheckVariable does not have a value. Did you run 'init.ps1 -InitEnv'?"
}
# END CUSTOMIZATION
}
# DEMO TEAM CUSTOMIZATION - Add ability to skip building the containers.
if (-not $SkipBuild) {
# Build all containers in the Sitecore instance, forcing a pull of latest base containers
Write-Host "Building containers..." -ForegroundColor Green
.\build-images.ps1
if ($LASTEXITCODE -ne 0) {
Write-Error "Container build failed, see errors above."
}
}
# END CUSTOMIZATION
# Start the Sitecore instance
Write-Host "Starting Sitecore environment..." -ForegroundColor Green
docker compose up -d
# Wait for Traefik to expose CM route
Write-Host "Waiting for CM to become available..." -ForegroundColor Green
$startTime = Get-Date
do {
Start-Sleep -Milliseconds 100
try {
$status = Invoke-RestMethod "http://localhost:8079/api/http/routers/cm-secure@docker"
}
catch {
if ($_.Exception.Response.StatusCode.value__ -ne "404") {
throw
}
}
} while ($status.status -ne "enabled" -and $startTime.AddSeconds(15) -gt (Get-Date))
if (-not $status.status -eq "enabled") {
$status
Write-Error "Timeout waiting for Sitecore CM to become available via Traefik proxy. Check CM container logs."
}
Write-Host "Opening sites..." -ForegroundColor Green
Start-Process https://cm.lighthouse.localhost/sitecore