-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathup.ps1
More file actions
89 lines (75 loc) · 3.13 KB
/
Copy pathup.ps1
File metadata and controls
89 lines (75 loc) · 3.13 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
[CmdletBinding(DefaultParameterSetName = "no-arguments")]
Param (
[Parameter(HelpMessage = "Alternative login using app client.",
ParameterSetName = "by-pass")]
[bool]$ByPass = $false
)
$topologyArray = "xp0", "xp1", "xm1";
$ErrorActionPreference = "Stop";
$startDirectory = ".\run\sitecore-";
$workingDirectoryPath;
$envCheck;
# Double check whether init has been run
$envCheckVariable = "HOST_LICENSE_FOLDER";
foreach ($topology in $topologyArray)
{
$envCheck = Get-Content (Join-Path -Path ($startDirectory + $topology) -ChildPath .env) -Encoding UTF8 | Where-Object { $_ -imatch "^$envCheckVariable=.+" }
if ($envCheck) {
$workingDirectoryPath = $startDirectory + $topology;
break
}
}
if (-not $envCheck) {
throw "$envCheckVariable does not have a value. Did you run 'init.ps1 -InitEnv'?"
}
Push-Location $workingDirectoryPath
# Build all containers in the Sitecore instance, forcing a pull of latest base containers
Write-Host "Building containers..." -ForegroundColor Green
docker-compose build
if ($LASTEXITCODE -ne 0) {
Write-Error "Container build failed, see errors above."
}
# Start the Sitecore instance
Write-Host "Starting Sitecore environment..." -ForegroundColor Green
docker-compose up -d
Pop-Location
# 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."
}
if ($ByPass) {
dotnet sitecore login --cm https://cm.kayeedictionaryservicedemo.localhost/ --auth https://id.kayeedictionaryservicedemo.localhost/ --allow-write true --client-id "SitecoreCLIServer" --client-secret "testsecret" --client-credentials true
}else {
dotnet sitecore login --cm https://cm.kayeedictionaryservicedemo.localhost/ --auth https://id.kayeedictionaryservicedemo.localhost/ --allow-write true
}
if ($LASTEXITCODE -ne 0) {
Write-Error "Unable to log into Sitecore, did the Sitecore environment start correctly? See logs above."
}
# Populate Solr managed schemas to avoid errors during item push
Write-Host "Populating Solr managed schema..." -ForegroundColor Green
dotnet sitecore index schema-populate
Write-Host "Pushing latest items to Sitecore..." -ForegroundColor Green
dotnet sitecore ser push --publish
if ($LASTEXITCODE -ne 0) {
Write-Error "Serialization push failed, see errors above."
}
Write-Host "Opening site..." -ForegroundColor Green
Start-Process https://cm.kayeedictionaryservicedemo.localhost/sitecore/
Start-Process https://www.kayeedictionaryservicedemo.localhost/
Write-Host ""
Write-Host "Use the following command to monitor your Rendering Host:" -ForegroundColor Green
Write-Host "docker-compose logs -f rendering"
Write-Host ""