Skip to content

Commit dbd2cdf

Browse files
authored
Merge pull request #3 from phaniav/main
Modified directory structure to support conversion of multiple packages
2 parents ec150d7 + 6e6f84b commit dbd2cdf

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

Create-SitecoreModule-DockerAssetImage.ps1

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@ else {
8787
Write-Host "START - [Convert Sitecore Module to .scwdp]"
8888
Write-Host "`n"
8989

90+
$dateTime = (Get-Date).tostring("ddMMyyyyHHmmss")
9091
$packagePath = $PSScriptRoot + "\Package\$ModulePackageName"
92+
$modulePackageItem = Get-Item $packagePath
93+
$modulePackageNameSinExtension = $modulePackageItem.BaseName
9194
$scwdpDirectory = $PSScriptRoot + "\scwdp"
95+
$scwdpModuleFolder = $modulePackageNameSinExtension + "_$dateTime"
96+
$scwdpDestination = "$scwdpDirectory\$scwdpModuleFolder"
97+
9298

9399
Import-Module .\SAT\tools\Sitecore.Cloud.Cmdlets.psm1
94100
Import-Module .\SAT\tools\Sitecore.Cloud.Cmdlets.dll
@@ -100,34 +106,35 @@ else {
100106
If (!(Test-Path($scwdpDirectory))) {
101107
New-Item -ItemType Directory -Force -Path $scwdpDirectory
102108
}
103-
104-
Get-ChildItem -Path $scwdpDirectory -Recurse | Foreach-object { Remove-item -Recurse -path $_.FullName }
105-
106-
$scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDirectory -Force
109+
110+
$scwdpPath = ConvertTo-SCModuleWebDeployPackage -Path $packagePath -Destination $scwdpDestination -Force
107111
Write-Host "SUCCESS - Your Sitecore Module was converted to a Sitecore WebDeploy package and is located at:" -ForegroundColor Green
108-
Write-Host "`n"
109-
Write-Host "$scwdpPath" -ForegroundColor Yellow
112+
Write-Host "`n"
113+
Write-Host "$scwdpDestination" -ForegroundColor Yellow
110114
Write-Host "`n"
111115

112116
Write-Host "=================================================================================================================================="
113117
Write-Host "`n"
114118
Write-Host "START - [Extracting Sitecore WebDeploy package]"
115119
Write-Host "`n"
116120

117-
$extractSCwdpDirectory = $scwdpDirectory + "\extract"
121+
$extractSCwdpDirectory = $scwdpDestination + "\extract_scwdp"
118122

119123
if (!(Test-Path($extractSCwdpDirectory))) {
120124
New-Item -ItemType Directory -Force -Path $extractSCwdpDirectory
121125
}
126+
127+
$extractSCwdpDirectory
122128

123129
Expand-Archive -Path "$scwdpPath" -DestinationPath "$extractSCwdpDirectory" -Force
124130

125131
Write-Host "=================================================================================================================================="
126132
Write-Host "`n"
127133
Write-Host "START - [Creating Sitecore module asset image structure]"
128134
Write-Host "`n"
129-
130-
$moduleDirectory = $PSScriptRoot + "\Module"
135+
136+
$moduleDirectory = "$scwdpDestination\Module"
137+
131138
$cmContentDirectory = $moduleDirectory + "\cm\content"
132139
$dbDirectory = $moduleDirectory + "\db"
133140
$solrDirectory = $moduleDirectory + "\solr"
@@ -137,8 +144,6 @@ else {
137144
New-Item -ItemType Directory -Force -Path $moduleDirectory
138145
}
139146

140-
Remove-Item -Path $moduleDirectory -Recurse
141-
142147
If (!(Test-Path($cmContentDirectory))) {
143148
New-Item -ItemType Directory -Force -Path $cmContentDirectory
144149
}
@@ -197,4 +202,4 @@ else {
197202
Show-Stop
198203

199204
# Cleaning up the modules
200-
Get-Module | Remove-Module
205+
Get-Module | Remove-Module

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# sitecore-module-docker-asset-image-creator
22
This repository contains a script to handle the auto creation of a Docker Asset Image for a given Sitecore module
33

4+
- Clone the repo to your working machine
5+
- Add the Sitecore module package to Package folder under root
6+
- 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
7+
```powershell
8+
.\Create-SitecoreModule-DockerAssetImage.ps1 -ModulePackageName "Brightcove.Media.Framework-10.0.zip"
9+
```
10+
- The folder name is generated based on the ModulePackageName provided while invoking the script and appends the current datetime stamp in `ModulePackageName_ddMMyyyyHHmmss` format
11+
- 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
12+
- 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
13+
14+
![image](https://user-images.githubusercontent.com/3968213/129932632-67ee772f-63da-421e-a476-dfe08635ca69.png)
15+
416
# Contributors
517
Robbert Hock - Twitter: @kayeeNL, GitHub: https://github.com/KayeeNL

0 commit comments

Comments
 (0)