Skip to content
This repository was archived by the owner on Oct 8, 2019. It is now read-only.

Commit e74b5ea

Browse files
joostmeijlesJonne
authored andcommitted
Add default entrypoint that watch directories (#27)
1 parent 5ff72d0 commit e74b5ea

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

commerce/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,9 @@ RUN Expand-Archive -Path "/Files/$Env:PLUMBER_FILE_NAME" -DestinationPath 'c:\\i
284284
}
285285

286286
# Expose Plumber port
287-
EXPOSE 4000
287+
EXPOSE 4000
288+
289+
ADD commerce/WatchDirectoryMultiple.ps1 /Scripts
290+
ADD commerce/WatchDefaultDirectories.ps1 /Scripts
291+
292+
ENTRYPOINT /Scripts/WatchDefaultDirectories.ps1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:\Scripts\WatchDirectoryMultiple.ps1 -Path C:\Workspace -Destinations @('C:\\inetpub\\wwwroot\\CommerceAuthoring_Sc9', 'C:\\inetpub\\wwwroot\\CommerceMinions_Sc9', 'C:\\inetpub\\wwwroot\\CommerceOps_Sc9', 'C:\\inetpub\\wwwroot\\CommerceShops_Sc9')

scripts/Watch-Directory.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ try
7272
# Main loop
7373
while ($true)
7474
{
75-
Sync -Path $Path -Destination $Destination
75+
Sync -Path $Path -Destination $Destination | Write-Host
7676

7777
Start-Sleep -Milliseconds 200
7878
}

scripts/WatchDirectoryMultiple.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
[CmdletBinding()]
3+
param(
4+
# Path to watch for changes
5+
[Parameter(Mandatory=$true)]
6+
[ValidateScript({Test-Path $_ -PathType 'Container'})]
7+
$Path,
8+
# Array Destination path to keep updated
9+
[Parameter(Mandatory=$true)]
10+
[array]$Destinations,
11+
# Array of filename patterns (-like operator) to ignore
12+
[Parameter(Mandatory=$false)]
13+
[array]$Ignore = @("*\obj\*", "*.cs", "*.csproj", "*.user")
14+
)
15+
16+
function Sync
17+
{
18+
Foreach($destination in $Destinations) {
19+
$dirty = $false
20+
$raw = (robocopy $Path $destination /E /XX /MT:1 /NJH /NJS /FP /NDL /NP /NS /R:5 /W:1 /XD obj /XF *.user /XF *ncrunch* /XF *.cs)
21+
$raw | ForEach-Object {
22+
$line = $_.Trim().Replace("`r`n", "").Replace("`t", " ")
23+
$dirty = ![string]::IsNullOrEmpty($line)
24+
25+
if ($dirty)
26+
{
27+
Write-Host ("{0}: {1}" -f [DateTime]::Now.ToString("HH:mm:ss:fff"), $line) -ForegroundColor DarkGray
28+
}
29+
}
30+
31+
if ($dirty)
32+
{
33+
Write-Host ("{0}: Done syncing..." -f [DateTime]::Now.ToString("HH:mm:ss:fff")) -ForegroundColor Green
34+
}
35+
}
36+
}
37+
38+
# Initial sync
39+
Sync | Out-Null
40+
41+
Foreach($destination in $Destinations) {
42+
Write-Host ("{0}: Watching '{1}' for changes, will copy to '{2}' while ignoring '{3}'." -f [DateTime]::Now.ToString("HH:mm:ss:fff"), $Path, $destination, ($Ignore -join ", "))
43+
}
44+
45+
# Start
46+
while($true) {
47+
Sync | Write-Host
48+
49+
Sleep -Milliseconds 500
50+
}

sitecore/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ RUN /Scripts/Import-Certificate.ps1 -certificateFile /Files/$Env:ROOT_CERT_PATH
4141
# Import XConnect certificate
4242
RUN /Scripts/Import-Certificate.ps1 -certificateFile /Files/$Env:COMMERCE_CERT_PATH -secret 'secret' -storeName 'My' -storeLocation 'LocalMachine'
4343
RUN /Scripts/Import-Certificate.ps1 -certificateFile /Files/$Env:ROOT_CERT_PATH -secret 'secret' -storeName 'My' -storeLocation 'LocalMachine'
44+
45+
ENTRYPOINT /Scripts/Watch-Directory.ps1 -Path C:\Workspace -Destination c:\inetpub\wwwroot\sitecore

0 commit comments

Comments
 (0)