forked from Sitecore/MVP-Site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup.ps1
63 lines (52 loc) · 1.99 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
# ENSURE ENV FILE EXISTS
if(-not (Test-Path .env)) {
Write-Host "Docker Env file not found. Have you run init.ps1 first? Refer to README.md for details" -ForegroundColor Red
exit
}
# Restore dotnet tool for sitecore login and serialization
dotnet tool restore
# Build all containers in the Sitecore instance, forcing a pull of latest base containers
docker-compose build
if ($LASTEXITCODE -ne 0)
{
Write-Error "Container build failed, see errors above."
}
# Run the docker containers
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."
}
dotnet sitecore login --cm https://mvp-cm.sc.localhost/ --auth https://mvp-id.sc.localhost/ --allow-write true
if ($LASTEXITCODE -ne 0) {
Write-Error "Unable to log into Sitecore, did the Sitecore environment start correctly? See logs above."
}
Write-Host "Pushing latest items to Sitecore..." -ForegroundColor Green
dotnet sitecore ser push
if ($LASTEXITCODE -ne 0) {
Write-Error "Serialization push failed, see errors above."
}
dotnet sitecore publish
if ($LASTEXITCODE -ne 0) {
Write-Error "Item publish failed, see errors above."
}
Write-Host "Opening site..." -ForegroundColor Green
Start-Process https://mvp-cm.sc.localhost/sitecore/
Start-Process https://mvp.sc.localhost/
Write-Host ""
Write-Host "Use the following command to monitor your Rendering Host:" -ForegroundColor Green
Write-Host "docker-compose logs -f mvp-rendering"
Write-Host ""