-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
80 lines (66 loc) · 2.78 KB
/
build.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
80
[CmdletBinding()]
param(
[string[]]$Services,
[switch]$IncludeSps,
[switch]$IncludeSpe,
[switch]$IncludeSxa,
[switch]$IncludePackages
)
$releases = Join-Path -Path $PSScriptRoot -ChildPath ".\docker\build\releases"
$extract = Join-Path -Path $releases -ChildPath "extract"
$content = Join-Path -Path $PSScriptRoot -ChildPath ".\docker\build\cm\content"
$db = Join-Path -Path $PSScriptRoot -ChildPath ".\docker\build\mssql-init\db"
if(-not (Test-Path -Path $extract)) {
New-Item -Path $extract -ItemType Directory > $null
}
Remove-Item -Path "$($content)\*" -Recurse
Remove-Item -Path "$($db)\*" -Recurse
if($IncludePackages) {
$counter = 0
$archives = Get-ChildItem -Path "$($releases)\*.zip"
foreach($archive in $archives) {
Remove-Item -Path "$($extract)\*" -Recurse
if($archive.Name.EndsWith(".scwdp.zip")) {
$archive | Expand-Archive -DestinationPath $extract -Force
Copy-Item -Path "$($extract)\Content\Website\*" -Destination $content -Recurse -Force
} elseif($archive.Name.EndsWith(".zip")) {
$archive | Expand-Archive -DestinationPath $extract -Force
Copy-Item -Path "$($extract)\*" -Destination $content -Recurse -Force
}
$dacpacs = Get-ChildItem -Path $extract -Filter "*.dacpac"
if($dacpacs) {
$databaseDirectory = Join-Path -Path $db -ChildPath "$($counter.ToString('D2'))"
New-Item -Path $databaseDirectory -ItemType Directory > $null
if (Test-Path("$($extract)\core.dacpac")) {
Copy-Item -Path "$($extract)\core.dacpac" -Destination $databaseDirectory -PassThru
Rename-Item -Path "$($databaseDirectory)\core.dacpac" -NewName "Sitecore.Core.dacpac"
}
if (Test-Path("$($extract)\master.dacpac")) {
Copy-Item -Path "$($extract)\master.dacpac" -Destination $databaseDirectory -PassThru
Rename-Item -Path "$($databaseDirectory)\master.dacpac" -NewName "Sitecore.Master.dacpac"
}
}
$counter++
}
}
$composeArgs = @("compose", "-f", ".\docker-compose.yml")
if(Test-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath "docker-compose.override.yml")) {
$composeArgs += "-f"
$composeArgs += ".\docker-compose.override.yml"
}
$composeArgs += "-f"
$composeArgs += ".\docker-compose.build.yml"
if($IncludeSps) {
$composeArgs += "-f"
$composeArgs += ".\docker-compose.sps.yml"
}
if($IncludeSpe -or $IncludeSxa) {
$composeArgs += "-f"
$composeArgs += ".\docker-compose.spe.yml"
}
if($IncludeSxa) {
$composeArgs += "-f"
$composeArgs += ".\docker-compose.sxa.yml"
}
Write-Host Building
docker $composeArgs build $Services