Skip to content

Commit

Permalink
Merge pull request #3 from phaniav/main
Browse files Browse the repository at this point in the history
Modified directory structure to support conversion of multiple packages
  • Loading branch information
KayeeNL authored Mar 15, 2022
2 parents ec150d7 + 6e6f84b commit dbd2cdf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Create-SitecoreModule-DockerAssetImage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,34 +106,35 @@ 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

$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"

Write-Host "=================================================================================================================================="
Write-Host "`n"
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

Write-Host "=================================================================================================================================="
Write-Host "`n"
Write-Host "START - [Creating Sitecore module asset image structure]"
Write-Host "`n"

$moduleDirectory = $PSScriptRoot + "\Module"

$moduleDirectory = "$scwdpDestination\Module"

$cmContentDirectory = $moduleDirectory + "\cm\content"
$dbDirectory = $moduleDirectory + "\db"
$solrDirectory = $moduleDirectory + "\solr"
Expand All @@ -137,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
}
Expand Down Expand Up @@ -197,4 +202,4 @@ else {
Show-Stop

# Cleaning up the modules
Get-Module | Remove-Module
Get-Module | Remove-Module
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dbd2cdf

Please sign in to comment.