From 3d45fe79797583b5dd6c737134110ea789f82ff5 Mon Sep 17 00:00:00 2001 From: phani-av Date: Wed, 18 Aug 2021 08:56:25 -0500 Subject: [PATCH 1/4] Update Create-SitecoreModule-DockerAssetImage.ps1 Added the ability to use the same script for converting Sitecore module packages to container images through updates to directory structure. --- Create-SitecoreModule-DockerAssetImage.ps1 | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Create-SitecoreModule-DockerAssetImage.ps1 b/Create-SitecoreModule-DockerAssetImage.ps1 index 7effa82..9f0b248 100644 --- a/Create-SitecoreModule-DockerAssetImage.ps1 +++ b/Create-SitecoreModule-DockerAssetImage.ps1 @@ -87,8 +87,14 @@ else { Write-Host "START - [Convert Sitecore Module to .scwdp]" Write-Host "`n" + $dateTime = (Get-Date).tostring("ddMMyyyyhhmmss") $packagePath = $PSScriptRoot + "\Package\$ModulePackageName" + $modulePackageItem = Get-Item $packagePath + $modulePackageNameSinExtension = $modulePackageItem.BaseName $scwdpDirectory = $PSScriptRoot + "\scwdp" + $scwdpModuleFolder = $modulePackageNameSinExtension + "_$dateTime" + $scwdpDestination = "$scwdpDirectory\$scwdpModuleFolder" + Import-Module .\SAT\tools\Sitecore.Cloud.Cmdlets.psm1 Import-Module .\SAT\tools\Sitecore.Cloud.Cmdlets.dll @@ -100,13 +106,19 @@ else { If (!(Test-Path($scwdpDirectory))) { New-Item -ItemType Directory -Force -Path $scwdpDirectory } - - Get-ChildItem -Path $scwdpDirectory -Recurse | Foreach-object { Remove-item -Recurse -path $_.FullName } - - $scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDirectory -Force + + # no need to delete existing scwdp + #Get-ChildItem -Path $scwdpDirectory -Recurse | Foreach-object { Remove-item -Recurse -path $_.FullName } + + #original + #$scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDirectory -Force + + #new + $scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDestination -Force Write-Host "SUCCESS - Your Sitecore Module was converted to a Sitecore WebDeploy package and is located at:" -ForegroundColor Green Write-Host "`n" - Write-Host "$scwdpPath" -ForegroundColor Yellow + #Write-Host "$scwdpPath" -ForegroundColor Yellow + Write-Host "$scwdpDestination" -ForegroundColor Yellow Write-Host "`n" Write-Host "==================================================================================================================================" @@ -114,11 +126,13 @@ else { Write-Host "START - [Extracting Sitecore WebDeploy package]" Write-Host "`n" - $extractSCwdpDirectory = $scwdpDirectory + "\extract" + $extractSCwdpDirectory = $scwdpDestination + "\extract_scwdp" if (!(Test-Path($extractSCwdpDirectory))) { New-Item -ItemType Directory -Force -Path $extractSCwdpDirectory } + + $extractSCwdpDirectory Expand-Archive -Path "$scwdpPath" -DestinationPath "$extractSCwdpDirectory" -Force @@ -127,7 +141,9 @@ else { Write-Host "START - [Creating Sitecore module asset image structure]" Write-Host "`n" - $moduleDirectory = $PSScriptRoot + "\Module" + #$moduleDirectory = $PSScriptRoot + "\$scwdpModuleFolder\Module" + $moduleDirectory = "$scwdpDestination\Module" + $cmContentDirectory = $moduleDirectory + "\cm\content" $dbDirectory = $moduleDirectory + "\db" $solrDirectory = $moduleDirectory + "\solr" @@ -137,7 +153,7 @@ else { New-Item -ItemType Directory -Force -Path $moduleDirectory } - Remove-Item -Path $moduleDirectory -Recurse + #Remove-Item -Path $moduleDirectory -Recurse If (!(Test-Path($cmContentDirectory))) { New-Item -ItemType Directory -Force -Path $cmContentDirectory @@ -197,4 +213,4 @@ else { Show-Stop # Cleaning up the modules -Get-Module | Remove-Module \ No newline at end of file +Get-Module | Remove-Module From e1bd1514e0207f5814aeb1d733d8b20fa4045abc Mon Sep 17 00:00:00 2001 From: phani-av Date: Wed, 18 Aug 2021 10:30:40 -0500 Subject: [PATCH 2/4] cleaned up comments --- Create-SitecoreModule-DockerAssetImage.ps1 | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Create-SitecoreModule-DockerAssetImage.ps1 b/Create-SitecoreModule-DockerAssetImage.ps1 index 9f0b248..53cf3ff 100644 --- a/Create-SitecoreModule-DockerAssetImage.ps1 +++ b/Create-SitecoreModule-DockerAssetImage.ps1 @@ -107,17 +107,9 @@ else { New-Item -ItemType Directory -Force -Path $scwdpDirectory } - # no need to delete existing scwdp - #Get-ChildItem -Path $scwdpDirectory -Recurse | Foreach-object { Remove-item -Recurse -path $_.FullName } - - #original - #$scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDirectory -Force - - #new $scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDestination -Force Write-Host "SUCCESS - Your Sitecore Module was converted to a Sitecore WebDeploy package and is located at:" -ForegroundColor Green - Write-Host "`n" - #Write-Host "$scwdpPath" -ForegroundColor Yellow + Write-Host "`n" Write-Host "$scwdpDestination" -ForegroundColor Yellow Write-Host "`n" @@ -140,8 +132,7 @@ else { Write-Host "`n" Write-Host "START - [Creating Sitecore module asset image structure]" Write-Host "`n" - - #$moduleDirectory = $PSScriptRoot + "\$scwdpModuleFolder\Module" + $moduleDirectory = "$scwdpDestination\Module" $cmContentDirectory = $moduleDirectory + "\cm\content" @@ -153,8 +144,6 @@ else { New-Item -ItemType Directory -Force -Path $moduleDirectory } - #Remove-Item -Path $moduleDirectory -Recurse - If (!(Test-Path($cmContentDirectory))) { New-Item -ItemType Directory -Force -Path $cmContentDirectory } From 1fc4f9384ccf43f3ca4eb08b6b993f708671da78 Mon Sep 17 00:00:00 2001 From: phani-av Date: Wed, 18 Aug 2021 11:09:27 -0500 Subject: [PATCH 3/4] Updated README.md Added description for how to use the repo. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index b732e17..39d071c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # sitecore-module-docker-asset-image-creator This repository contains a script to handle the auto creation of a Docker Asset Image for a given Sitecore module +- Clone the repo to your working machine +- Add the Sitecore module package to Package folder under root +- Then invoke the script as shown in example below to convert it into scwdp (used for Azure PaaS) as well as extract the scwdp into a Module folder used for generating the docker image + ```powershell + .\Create-SitecoreModule-DockerAssetImage.ps1 -ModulePackageName "Brightcove.Media.Framework-10.0.zip" + ``` +- The folder name is generated based on the ModulePackageName provided while invoking the script and appends the current datetime stamp in `ModulePackageName_ddMMyyyyHHmmss` format +- Run the docker file under Module folder to generate the image. The script only extracts it for CM role. For other roles, you have to manually create role specific docker files +- Once the image is generated, push it to your container registry to share it with other devs in your team or devops for AKS deployment + +![image](https://user-images.githubusercontent.com/3968213/129932632-67ee772f-63da-421e-a476-dfe08635ca69.png) + # Contributors Robbert Hock - Twitter: @kayeeNL, GitHub: https://github.com/KayeeNL From 6e6f84bd4eac0399d29c75b2df0c7b1554ee0e94 Mon Sep 17 00:00:00 2001 From: phani-av Date: Wed, 18 Aug 2021 11:10:47 -0500 Subject: [PATCH 4/4] update Create-SitecoreModule-DockerAssetImage.ps1 updated date format in script from ddMMyyyyhhmmss to ddMMyyyyHHmmss --- Create-SitecoreModule-DockerAssetImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Create-SitecoreModule-DockerAssetImage.ps1 b/Create-SitecoreModule-DockerAssetImage.ps1 index 53cf3ff..dfaf294 100644 --- a/Create-SitecoreModule-DockerAssetImage.ps1 +++ b/Create-SitecoreModule-DockerAssetImage.ps1 @@ -87,7 +87,7 @@ else { Write-Host "START - [Convert Sitecore Module to .scwdp]" Write-Host "`n" - $dateTime = (Get-Date).tostring("ddMMyyyyhhmmss") + $dateTime = (Get-Date).tostring("ddMMyyyyHHmmss") $packagePath = $PSScriptRoot + "\Package\$ModulePackageName" $modulePackageItem = Get-Item $packagePath $modulePackageNameSinExtension = $modulePackageItem.BaseName