Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XC PS images (#265) #3

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions IMAGES.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[//]: # "start: stats"

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](https://opensource.org/licenses/MIT) ![Repositories](https://img.shields.io/badge/Repositories-98-blue.svg?style=flat-square) ![Tags](https://img.shields.io/badge/Tags-510-blue.svg?style=flat-square) ![Deprecated](https://img.shields.io/badge/Deprecated-0-lightgrey.svg?style=flat-square) ![Dockerfiles](https://img.shields.io/badge/Dockerfiles-83-blue.svg?style=flat-square) ![Default version](https://img.shields.io/badge/Default%20version-9.3.0%20on%20ltsc2019/1809-blue?style=flat-square)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](https://opensource.org/licenses/MIT) ![Repositories](https://img.shields.io/badge/Repositories-104-blue.svg?style=flat-square) ![Tags](https://img.shields.io/badge/Tags-528-blue.svg?style=flat-square) ![Deprecated](https://img.shields.io/badge/Deprecated-0-lightgrey.svg?style=flat-square) ![Dockerfiles](https://img.shields.io/badge/Dockerfiles-86-blue.svg?style=flat-square) ![Default version](https://img.shields.io/badge/Default%20version-9.3.0%20on%20ltsc2019/1809-blue?style=flat-square)

[//]: # "end: stats"

Expand Down
4 changes: 2 additions & 2 deletions windows/9.2.x/sitecore-xc-sxa-storefront-sqldev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ARG ASSETS_USE_WDP_SXA_STOREFRONT_CATALOG
ENV INSTALL_PATH='C:\\install\\' `
INSTALL_MODULE_PATH='C:\\install-module\\' `
DATA_PATH='C:\\data\\' `
TEMP_PATH='c:\\temp'
TEMP_PATH='c:\\temp'

COPY --from=assets ["${ASSETS_USE_WDP_ADVENTUREWORKS_IMAGES}", "${INSTALL_MODULE_PATH}"]
COPY --from=assets ["${ASSETS_USE_WDP_HABITAT_IMAGES}", "${INSTALL_MODULE_PATH}"]
Expand All @@ -29,4 +29,4 @@ COPY . ${INSTALL_MODULE_PATH}
RUN & (Join-Path $env:INSTALL_MODULE_PATH "\\Extract-Databases.ps1") -Path $env:INSTALL_MODULE_PATH; `
& (Join-Path $env:INSTALL_MODULE_PATH "\\Install-Databases.ps1") -InstallPath $env:INSTALL_PATH -DataPath $env:DATA_PATH -ModulePath $env:INSTALL_MODULE_PATH -DatabasePrefix Sitecore; `
Get-ChildItem -Path $env:INSTALL_PATH -Exclude "*.mdf", "*.ldf" | Remove-Item -Force; `
Get-ChildItem -Path $env:INSTALL_MODULE_PATH -Include "*.*" | Remove-Item -Force;
Get-ChildItem -Path $env:INSTALL_MODULE_PATH | Remove-Item -Force -Recurse;
4 changes: 2 additions & 2 deletions windows/9.3.x/sitecore-xc-sxa-storefront-sqldev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ARG ASSETS_USE_WDP_SXA_STOREFRONT_CATALOG
ENV INSTALL_PATH='C:\\install\\' `
INSTALL_MODULE_PATH='C:\\install-module\\' `
DATA_PATH='C:\\data\\' `
TEMP_PATH='c:\\temp'
TEMP_PATH='c:\\temp'

COPY --from=assets ["${ASSETS_USE_WDP_ADVENTUREWORKS_IMAGES}", "${INSTALL_MODULE_PATH}"]
COPY --from=assets ["${ASSETS_USE_WDP_HABITAT_IMAGES}", "${INSTALL_MODULE_PATH}"]
Expand All @@ -29,4 +29,4 @@ COPY . ${INSTALL_MODULE_PATH}
RUN & (Join-Path $env:INSTALL_MODULE_PATH "\\Extract-Databases.ps1") -Path $env:INSTALL_MODULE_PATH; `
& (Join-Path $env:INSTALL_MODULE_PATH "\\Install-Databases.ps1") -InstallPath $env:INSTALL_PATH -DataPath $env:DATA_PATH -ModulePath $env:INSTALL_MODULE_PATH -DatabasePrefix Sitecore; `
Get-ChildItem -Path $env:INSTALL_PATH -Exclude "*.mdf", "*.ldf" | Remove-Item -Force; `
Get-ChildItem -Path $env:INSTALL_MODULE_PATH -Include "*.*" | Remove-Item -Force;
Get-ChildItem -Path $env:INSTALL_MODULE_PATH | Remove-Item -Force -Recurse;
21 changes: 21 additions & 0 deletions windows/9.x.x/sitecore-xc-ps-sqldev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# escape=`
ARG BASE_IMAGE
ARG ASSETS_IMAGE

FROM $ASSETS_IMAGE as assets
FROM $BASE_IMAGE

ARG ASSETS_USE_WDP

ENV INSTALL_PATH='C:\\install\\' `
INSTALL_MODULE_PATH='C:\\install-module\\' `
DATA_PATH='C:\\data\\' `
TEMP_PATH='c:\\temp'

COPY --from=assets ["${ASSETS_USE_WDP}", "${INSTALL_MODULE_PATH}"]
COPY . ${INSTALL_MODULE_PATH}

RUN & (Join-Path $env:INSTALL_MODULE_PATH "\\Extract-Databases.ps1") -Path $env:INSTALL_MODULE_PATH; `
& (Join-Path $env:INSTALL_MODULE_PATH "\\Install-Databases.ps1") -InstallPath $env:INSTALL_PATH -DataPath $env:DATA_PATH -ModulePath $env:INSTALL_MODULE_PATH -DatabasePrefix Sitecore; `
Get-ChildItem -Path $env:INSTALL_PATH -Exclude "*.mdf", "*.ldf" | Remove-Item -Force; `
Get-ChildItem -Path $env:INSTALL_MODULE_PATH | Remove-Item -Force;
35 changes: 35 additions & 0 deletions windows/9.x.x/sitecore-xc-ps-sqldev/Extract-Databases.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateScript( { Test-Path $_ -PathType 'Container' })]
[string]$Path
)

Add-Type -Assembly "System.IO.Compression"
Add-Type -Assembly "System.IO.Compression.FileSystem"

Get-ChildItem -Path $Path -Filter "*.zip" | ForEach-Object {
$zipPath = $_.FullName

try
{
$stream = New-Object IO.FileStream($zipPath, [IO.FileMode]::Open)
$zip = New-Object IO.Compression.ZipArchive($stream, [IO.Compression.ZipArchiveMode]::Read)

($zip.Entries | Where-Object { $_.FullName -like "*.dacpac" }) | Foreach-Object {
[IO.Compression.ZipFileExtensions]::ExtractToFile($_, (Join-Path $Path $_.Name), $true)
}
}
finally
{
if ($zip -ne $null)
{
$zip.Dispose()
}

if ($stream -ne $null)
{
$stream.Dispose()
}
}
}
63 changes: 63 additions & 0 deletions windows/9.x.x/sitecore-xc-ps-sqldev/Install-Databases.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateScript( { Test-Path $_ -PathType 'Container' })]
[string]$InstallPath,
[Parameter(Mandatory = $true)]
[ValidateScript( { Test-Path $_ -PathType 'Container' })]
[string]$DataPath,
[Parameter(Mandatory = $true)]
[ValidateScript( { Test-Path $_ -PathType 'Container' })]
[string]$ModulePath,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$DatabasePrefix
)

$timeFormat = "HH:mm:ss:fff"

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null

$server = New-Object Microsoft.SqlServer.Management.Smo.Server($env:COMPUTERNAME)
$server.Properties["DefaultFile"].Value = $InstallPath
$server.Properties["DefaultLog"].Value = $InstallPath
$server.Alter()

$sqlPackageExePath = Get-Item "C:\Program Files\Microsoft SQL Server\*\DAC\bin\SqlPackage.exe" | Select-Object -Last 1 -Property FullName -ExpandProperty FullName

# attach
Get-ChildItem -Path $InstallPath -Filter "*.mdf" | ForEach-Object {
$databaseName = $_.BaseName.Replace("_Primary", "")
$mdfPath = $_.FullName
$ldfPath = $mdfPath.Replace(".mdf", ".ldf")
$sqlcmd = "IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = '$databaseName') BEGIN EXEC sp_detach_db [$databaseName] END;CREATE DATABASE [$databaseName] ON (FILENAME = N'$mdfPath'), (FILENAME = N'$ldfPath') FOR ATTACH;"

Write-Host "$(Get-Date -Format $timeFormat): Attaching '$databaseName'..."

Invoke-Sqlcmd -Query $sqlcmd
}

# do modules
$TextInfo = (Get-Culture).TextInfo
Get-ChildItem -Path $ModulePath -Include "core.dacpac", "master.dacpac" -Recurse | ForEach-Object {

$dacpacPath = $_.FullName
$databaseName = "$DatabasePrefix`." + $TextInfo.ToTitleCase($_.BaseName)

# Install
& $sqlPackageExePath /a:Publish /sf:$dacpacPath /tdn:$databaseName /tsn:$env:COMPUTERNAME /q
}

# detach DB
Get-ChildItem -Path $InstallPath -Filter "*.mdf" | ForEach-Object {
$databaseName = $_.BaseName.Replace("_Primary", "")

Write-Host "$(Get-Date -Format $timeFormat): Detach: $databaseName"

Invoke-Sqlcmd -Query "EXEC MASTER.dbo.sp_detach_db @dbname = N'$databaseName', @keepfulltextindexfile = N'false'"
}

$server = New-Object Microsoft.SqlServer.Management.Smo.Server($env:COMPUTERNAME)
$server.Properties["DefaultFile"].Value = $DataPath
$server.Properties["DefaultLog"].Value = $DataPath
$server.Alter()
25 changes: 25 additions & 0 deletions windows/9.x.x/sitecore-xc-ps-sqldev/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"tags": [
{
"tag": "sitecore-xc-sxa-ps-sqldev:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--memory 4GB",
"--build-arg BASE_IMAGE=sitecore-xc-sxa-sqldev:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental":true
},
{
"tag": "sitecore-xc-sxa-storefront-ps-sqldev:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--memory 4GB",
"--build-arg BASE_IMAGE=sitecore-xc-sxa-storefront-sqldev:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental":true
}
],
"sources": []
}
29 changes: 29 additions & 0 deletions windows/9.x.x/sitecore-xc-ps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# escape=`
ARG BASE_IMAGE
ARG ASSETS_IMAGE

FROM $ASSETS_IMAGE as assets
FROM $BASE_IMAGE as build

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG ASSETS_USE_WDP

COPY --from=assets ["${ASSETS_USE_WDP}", "C:\\temp\\packages\\"]

# expand selected wdp into installation directory
RUN Expand-Archive -Path 'C:\\temp\\packages\\*.zip' -DestinationPath 'C:\\temp'; `
Copy-Item -Path 'C:\\temp\\Content\\Website\\*' -Destination 'C:\\inetpub\\wwwroot' -Recurse -Force;

# copy tools and transforms
COPY --from=assets ["C:\\install\\tools\\", "C:\\install\\tools\\"]

# find transform files and do transformation
RUN (Get-ChildItem -Path 'C:\\inetpub\\wwwroot\\*.xdt' -Recurse ) | ForEach-Object { & 'C:\\install\\tools\\scripts\\Invoke-XdtTransform.ps1' -Path 'C:\\inetpub\\wwwroot\\web.config' -XdtPath $_.FullName -XdtDllPath 'C:\\install\\tools\\bin\\Microsoft.Web.XmlTransform.dll'; };

FROM $BASE_IMAGE

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY --from=build ["C:\\inetpub\\wwwroot\\", "C:\\inetpub\\wwwroot\\"]

41 changes: 41 additions & 0 deletions windows/9.x.x/sitecore-xc-ps/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"tags": [
{
"tag": "sitecore-xc-sxa-ps-standalone:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--build-arg BASE_IMAGE=sitecore-xc-sxa-standalone:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental": true
},
{
"tag": "sitecore-xc-sxa-ps-cd:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--build-arg BASE_IMAGE=sitecore-xc-sxa-cd:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental": true
},
{
"tag": "sitecore-xc-sxa-storefront-ps-standalone:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--build-arg BASE_IMAGE=sitecore-xc-sxa-storefront-standalone:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental": true
},
{
"tag": "sitecore-xc-sxa-storefront-ps-cd:9.3.0-windowsservercore-${windowsservercore_version}",
"build-options": [
"--build-arg BASE_IMAGE=sitecore-xc-sxa-storefront-cd:9.3.0-windowsservercore-${windowsservercore_version}",
"--build-arg ASSETS_IMAGE=sitecore-assets:9.3.0-nanoserver-${nanoserver_version}",
"--build-arg ASSETS_USE_WDP='C:\\packages\\Sitecore Publishing Module 9.3.0.0.scwdp.zip'"
],
"experimental": true
}
],
"sources": []
}