diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cc519eef..2f9170671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ ## November 2019 +- [Added] New **optional** `ENTRYPOINT` scripts (log streaming, auto start watch and auto start remote debugger) for IIS based images. See [README.md](/README.md#optional-entrypoint-scripts) on how to use. - [Added] Windows 1909 is now also supported. You can override which platforms you want by setting the parameter `AutoGenerateWindowsVersionTags` when calling `Invoke-Build`, default value is: `"1909", "1903", "ltsc2019"`. ## October 2019 - [Added] Sitecore 9.2.0 XC images. -- [Added] New 9.2.0 `xp-xconnect-processingengine` images. See [#84](https://github.com/Sitecore/docker-images/issues/43). Thanks [@adoprog](https://github.com/adoprog) :+1: +- [Added] New 9.2.0 `xp-xconnect-processingengine` images. See [#43](https://github.com/Sitecore/docker-images/issues/43). Thanks [@adoprog](https://github.com/adoprog) :+1: - [Changed] Windows and Linux `spe` "Sitecore PowerShell Extensions" images updated to **v6.0**, indirectly *also* updating all `sxa` images. See [#84](https://github.com/Sitecore/docker-images/issues/84). Thanks [@michaellwest](https://github.com/michaellwest) :+1: - [Changed] The `c:\tools\scripts\Watch-Directory.ps1` no longer deletes destination directories, only files. See [#89](https://github.com/Sitecore/docker-images/issues/89). Thanks [@sshushliapin](https://github.com/sshushliapin) :+1: - [Fixed] The `c:\tools` folder was empty. diff --git a/README.md b/README.md index 7e5df654a..3081fb687 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ This will: When completed: 1. Place your Sitecore license file at `C:\license\license.xml`, or override location using the environment variable `LICENSE_PATH` like so: `$env:LICENSE_PATH="D:\my\sitecore\licenses"` -1. Switch directory to .\windows\tests\9.x.x\ Then run any of the docker-compose files, for example an XM with: `docker-compose --file .\docker-compose.xm.yml up` +1. Switch directory to `.\windows\tests\9.x.x\` and then run any of the docker-compose files, for example an XM with: `docker-compose --file .\docker-compose.xm.yml up` ### Setting up automated builds @@ -132,3 +132,27 @@ SitecoreImageBuilder\Invoke-Build ` -Registry $registry ` -Tags $tags ``` + +### Optional ENTRYPOINT scripts + +For IIS based images (such as the roles `cm`, `standalone` and `cd`) we now have a few scripts that can be used as `ENTRYPOINT` for development and production use. + +Using these `ENTRYPOINT` scripts enables you to observe Sitecore log entries in the `STDOUT` of containers in the foreground or by using commands such as `docker container logs` or `docker container attach`. + +`C:\tools\entrypoints\iis\Production.ps1` features: + +- Adds an UDP appender to all default log4net loggers. +- Starts `ServiceMonitor.exe` in the background. +- Starts `filebeat.exe` in the foreground and outputting to `STDOUT`. +- FileBeat inputs configured: + - IIS access logs, **disabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED=true` + - IIS error logs, **disabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED=true` + - Sitecore logs, **enabled** by default, can be switched using environment variable: `ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED=false` + +`C:\tools\entrypoints\iis\Development.ps1` features: + +- Same as `Production.ps1`. +- Starts the Visual Studio Remote Debugger `msvsmon.exe` in the background **if** the Visual Studio Remote Debugger directory is mounted into `C:\remote_debugger`. +- Starts the `Watch-Directory.ps1` script in the background **if** a directory is mounted into `C:\src`. + +See the `cm` and `cd` service in [windows/tests/9.x.x/docker-compose.xm.yml](windows/tests/9.x.x/docker-compose.xm.yml) for configuration examples. diff --git a/windows/9.0.2/sitecore-assets/Dockerfile b/windows/9.0.2/sitecore-assets/Dockerfile index 8bc8ae4be..4a050c976 100644 --- a/windows/9.0.2/sitecore-assets/Dockerfile +++ b/windows/9.0.2/sitecore-assets/Dockerfile @@ -11,7 +11,8 @@ RUN New-Item -Path 'C:\\downloads' -ItemType 'Directory' -Force | Out-Null; ` & curl.exe -sS -L -o c:\\downloads\\nuget.exe https://dist.nuget.org/win-x86-commandline/v5.2.0/nuget.exe; ` & curl.exe -sS -L -o C:\\downloads\\urlrewrite.msi https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi; ` & curl.exe -sS -L -o C:\\downloads\\vc_redist.exe https://aka.ms/vs/15/release/VC_redist.x64.exe; ` - & curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; + & curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; ` + & curl.exe -sS -L -o C:\\downloads\\filebeat.zip https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.1-windows-x86_64.zip; # copy local assets COPY *.zip C:\\downloads\\ @@ -31,6 +32,11 @@ RUN & 'C:\\install\\tools\\bin\\nuget.exe' install 'Microsoft.Web.Xdt' -Version Copy-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\lib\\netstandard2.0\\*.dll' -Destination 'C:\\install\\tools\\bin'; ` Remove-Item -Path (Get-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\').FullName -Recurse -Force; +# extract filebeat +RUN Expand-Archive -Path 'C:\\downloads\\filebeat.zip' -DestinationPath 'C:\\install\\tools\\bin' -Force; ` + Rename-Item -Path (Get-Item -Path 'C:\\install\\tools\\bin\\filebeat*windows*').FullName -NewName "filebeat"; ` + Remove-Item -Path 'C:\\downloads\\filebeat.zip' -Force; + # extract assets, skip wdps, move already extracted wdps RUN $zips = Get-ChildItem -Path 'C:\\downloads\\*.zip' -Exclude '*.scwdp.zip'; ` $zips | ForEach-Object { ` @@ -46,7 +52,7 @@ RUN New-Item -Path 'C:\\install\\setup' -ItemType 'Directory' -Force | Out-Null; Get-ChildItem 'C:\\downloads\\*.*' -Include '*.exe', '*.msi' | Move-Item -Destination 'C:\\install\\setup'; # add tools folder -COPY tools C:\\install\\tools +COPY tools\\ C:\\install\\tools\\ FROM $BASE_IMAGE diff --git a/windows/9.0.2/sitecore-assets/entrypoints/iis/Development.ps1 b/windows/9.0.2/sitecore-assets/entrypoints/iis/Development.ps1 new file mode 100644 index 000000000..28afc93c0 --- /dev/null +++ b/windows/9.0.2/sitecore-assets/entrypoints/iis/Development.ps1 @@ -0,0 +1,163 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Development ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# check to see if we should start the msvsmon.exe +$useVsDebugger = (Test-Path -Path "C:\remote_debugger\x64\msvsmon.exe" -PathType "Leaf") -eq $true + +if ($useVsDebugger) +{ + # start msvsmon.exe in background + & "C:\remote_debugger\x64\msvsmon.exe" /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646 + + Write-Host ("### Started 'msvsmon.exe'.") +} +else +{ + Write-Host ("### Skipping start of 'msvsmon.exe', to enable you should mount the Visual Studio Remote Debugger directory into 'C:\remote_debugger'.") +} + +# check to see if we should start the Watch-Directory.ps1 script +$useWatchDirectory = (Test-Path -Path "C:\src" -PathType "Container") -eq $true + +if ($useWatchDirectory) +{ + # start Watch-Directory.ps1 in background, kill foreground process if it fails + Start-Job -Name "WatchDirectory.ps1" { + try + { + # TODO: Handle additional Watch-Directory params, use param splattering? + + & "C:\tools\scripts\Watch-Directory.ps1" -Path "C:\src" -Destination "C:\inetpub\wwwroot" -ExcludeFiles "Web.config" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } + } | ForEach-Object { + Write-Host ("### Started '$($_.Name)'.") + } +} +else +{ + Write-Host ("### Skipping start of 'WatchDirectory.ps1', to enable you should mount a directory into 'C:\src'.") +} + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.0.2/sitecore-assets/entrypoints/iis/EnableUdpLogging.config b/windows/9.0.2/sitecore-assets/entrypoints/iis/EnableUdpLogging.config new file mode 100644 index 000000000..47b1e66a9 --- /dev/null +++ b/windows/9.0.2/sitecore-assets/entrypoints/iis/EnableUdpLogging.config @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/windows/9.0.2/sitecore-assets/entrypoints/iis/Production.ps1 b/windows/9.0.2/sitecore-assets/entrypoints/iis/Production.ps1 new file mode 100644 index 000000000..7daaad66b --- /dev/null +++ b/windows/9.0.2/sitecore-assets/entrypoints/iis/Production.ps1 @@ -0,0 +1,122 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Production ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.0.2/sitecore-assets/entrypoints/iis/filebeat.yml b/windows/9.0.2/sitecore-assets/entrypoints/iis/filebeat.yml new file mode 100644 index 000000000..b66525024 --- /dev/null +++ b/windows/9.0.2/sitecore-assets/entrypoints/iis/filebeat.yml @@ -0,0 +1,19 @@ +filebeat.modules: +- module: iis + access: + enabled: ${ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED:false} + var.paths: ["C:/inetpub/logs/LogFiles/*/*.log"] + error: + enabled: ${ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED:false} + var.paths: ["C:/Windows/System32/LogFiles/HTTPERR/*.log"] + +filebeat.inputs: +- type: udp + enabled: ${ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED:true} + max_message_size: 100KiB + host: "127.0.0.1:7777" + +output.console: + pretty: true + codec.format: + string: '%{[message]}' \ No newline at end of file diff --git a/windows/9.1.1/sitecore-assets/Dockerfile b/windows/9.1.1/sitecore-assets/Dockerfile index e645e7324..53e4a7e2d 100644 --- a/windows/9.1.1/sitecore-assets/Dockerfile +++ b/windows/9.1.1/sitecore-assets/Dockerfile @@ -11,7 +11,8 @@ RUN New-Item -Path 'C:\\downloads' -ItemType 'Directory' -Force | Out-Null; ` & curl.exe -sS -L -o c:\\downloads\\nuget.exe https://dist.nuget.org/win-x86-commandline/v5.2.0/nuget.exe; ` & curl.exe -sS -L -o C:\\downloads\\urlrewrite.msi https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi; ` & curl.exe -sS -L -o C:\\downloads\\vc_redist.exe https://aka.ms/vs/15/release/VC_redist.x64.exe; ` - & curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; + & curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; ` + & curl.exe -sS -L -o C:\\downloads\\filebeat.zip https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.1-windows-x86_64.zip; # copy local assets COPY *.zip C:\\downloads\\ @@ -31,6 +32,11 @@ RUN & 'C:\\install\\tools\\bin\\nuget.exe' install 'Microsoft.Web.Xdt' -Version Copy-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\lib\\netstandard2.0\\*.dll' -Destination 'C:\\install\\tools\\bin'; ` Remove-Item -Path (Get-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\').FullName -Recurse -Force; +# extract filebeat +RUN Expand-Archive -Path 'C:\\downloads\\filebeat.zip' -DestinationPath 'C:\\install\\tools\\bin' -Force; ` + Rename-Item -Path (Get-Item -Path 'C:\\install\\tools\\bin\\filebeat*windows*').FullName -NewName "filebeat"; ` + Remove-Item -Path 'C:\\downloads\\filebeat.zip' -Force; + # extract assets, skip wdps, move already extracted wdps RUN $zips = Get-ChildItem -Path 'C:\\downloads\\*.zip' -Exclude '*.scwdp.zip'; ` $zips | ForEach-Object { Expand-Archive -Path $_.FullName -DestinationPath 'C:\\packages' -Force; }; ` @@ -43,7 +49,7 @@ RUN New-Item -Path 'C:\\install\\setup' -ItemType 'Directory' -Force | Out-Null; Get-ChildItem 'C:\\downloads\\*.*' -Include '*.exe', '*.msi' | Move-Item -Destination 'C:\\install\\setup'; # add tools folder -COPY tools C:\\install\\tools +COPY tools\\ C:\\install\\tools\\ FROM $BASE_IMAGE diff --git a/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Development.ps1 b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Development.ps1 new file mode 100644 index 000000000..28afc93c0 --- /dev/null +++ b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Development.ps1 @@ -0,0 +1,163 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Development ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# check to see if we should start the msvsmon.exe +$useVsDebugger = (Test-Path -Path "C:\remote_debugger\x64\msvsmon.exe" -PathType "Leaf") -eq $true + +if ($useVsDebugger) +{ + # start msvsmon.exe in background + & "C:\remote_debugger\x64\msvsmon.exe" /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646 + + Write-Host ("### Started 'msvsmon.exe'.") +} +else +{ + Write-Host ("### Skipping start of 'msvsmon.exe', to enable you should mount the Visual Studio Remote Debugger directory into 'C:\remote_debugger'.") +} + +# check to see if we should start the Watch-Directory.ps1 script +$useWatchDirectory = (Test-Path -Path "C:\src" -PathType "Container") -eq $true + +if ($useWatchDirectory) +{ + # start Watch-Directory.ps1 in background, kill foreground process if it fails + Start-Job -Name "WatchDirectory.ps1" { + try + { + # TODO: Handle additional Watch-Directory params, use param splattering? + + & "C:\tools\scripts\Watch-Directory.ps1" -Path "C:\src" -Destination "C:\inetpub\wwwroot" -ExcludeFiles "Web.config" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } + } | ForEach-Object { + Write-Host ("### Started '$($_.Name)'.") + } +} +else +{ + Write-Host ("### Skipping start of 'WatchDirectory.ps1', to enable you should mount a directory into 'C:\src'.") +} + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config new file mode 100644 index 000000000..47b1e66a9 --- /dev/null +++ b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Production.ps1 b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Production.ps1 new file mode 100644 index 000000000..7daaad66b --- /dev/null +++ b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/Production.ps1 @@ -0,0 +1,122 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Production ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/filebeat.yml b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/filebeat.yml new file mode 100644 index 000000000..b66525024 --- /dev/null +++ b/windows/9.1.1/sitecore-assets/tools/entrypoints/iis/filebeat.yml @@ -0,0 +1,19 @@ +filebeat.modules: +- module: iis + access: + enabled: ${ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED:false} + var.paths: ["C:/inetpub/logs/LogFiles/*/*.log"] + error: + enabled: ${ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED:false} + var.paths: ["C:/Windows/System32/LogFiles/HTTPERR/*.log"] + +filebeat.inputs: +- type: udp + enabled: ${ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED:true} + max_message_size: 100KiB + host: "127.0.0.1:7777" + +output.console: + pretty: true + codec.format: + string: '%{[message]}' \ No newline at end of file diff --git a/windows/9.2.0/sitecore-assets/Dockerfile b/windows/9.2.0/sitecore-assets/Dockerfile index bedd6c1d7..46886a32d 100644 --- a/windows/9.2.0/sitecore-assets/Dockerfile +++ b/windows/9.2.0/sitecore-assets/Dockerfile @@ -12,6 +12,7 @@ RUN New-Item -Path 'C:\\downloads' -ItemType 'Directory' -Force | Out-Null; ` & curl.exe -sS -L -o C:\\downloads\\urlrewrite.msi https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi; ` & curl.exe -sS -L -o C:\\downloads\\vc_redist.exe https://aka.ms/vs/15/release/VC_redist.x64.exe; ` & curl.exe -sS -L -o C:\\downloads\\7z-installer.exe https://www.7-zip.org/a/7z1900-x64.exe; ` + & curl.exe -sS -L -o C:\\downloads\\filebeat.zip https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.1-windows-x86_64.zip; ` & curl.exe -sS -L -o C:\\downloads\\dotnet-hosting.exe https://download.visualstudio.microsoft.com/download/pr/34f4b2a6-c3b8-495c-a11f-6db955f27757/8c340c1a8c25966e39e0c0a4b308dff4/dotnet-hosting-2.2.5-win.exe; # copy local assets @@ -33,6 +34,11 @@ RUN & 'C:\\install\\tools\\bin\\nuget.exe' install 'Microsoft.Web.Xdt' -Version Copy-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\lib\\netstandard2.0\\*.dll' -Destination 'C:\\install\\tools\\bin'; ` Remove-Item -Path (Get-Item -Path 'C:\\install\\Microsoft.Web.Xdt*\\').FullName -Recurse -Force; +# extract filebeat +RUN Expand-Archive -Path 'C:\\downloads\\filebeat.zip' -DestinationPath 'C:\\install\\tools\\bin' -Force; ` + Rename-Item -Path (Get-Item -Path 'C:\\install\\tools\\bin\\filebeat*windows*').FullName -NewName "filebeat"; ` + Remove-Item -Path 'C:\\downloads\\filebeat.zip' -Force; + # extract assets, skip wdps, move already extracted wdps RUN $zips = Get-ChildItem -Path 'C:\\downloads\\*.zip' -Exclude '*.scwdp.zip'; ` $zips | ForEach-Object { Expand-Archive -Path $_.FullName -DestinationPath 'C:\\packages' -Force; }; ` @@ -45,7 +51,7 @@ RUN New-Item -Path 'C:\\install\\setup' -ItemType 'Directory' -Force | Out-Null; Get-ChildItem 'C:\\downloads\\*.*' -Include '*.exe', '*.msi' | Move-Item -Destination 'C:\\install\\setup'; # add tools folder -COPY tools C:\\install\\tools +COPY tools\\ C:\\install\\tools\\ FROM $BASE_IMAGE diff --git a/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Development.ps1 b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Development.ps1 new file mode 100644 index 000000000..28afc93c0 --- /dev/null +++ b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Development.ps1 @@ -0,0 +1,163 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Development ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# check to see if we should start the msvsmon.exe +$useVsDebugger = (Test-Path -Path "C:\remote_debugger\x64\msvsmon.exe" -PathType "Leaf") -eq $true + +if ($useVsDebugger) +{ + # start msvsmon.exe in background + & "C:\remote_debugger\x64\msvsmon.exe" /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646 + + Write-Host ("### Started 'msvsmon.exe'.") +} +else +{ + Write-Host ("### Skipping start of 'msvsmon.exe', to enable you should mount the Visual Studio Remote Debugger directory into 'C:\remote_debugger'.") +} + +# check to see if we should start the Watch-Directory.ps1 script +$useWatchDirectory = (Test-Path -Path "C:\src" -PathType "Container") -eq $true + +if ($useWatchDirectory) +{ + # start Watch-Directory.ps1 in background, kill foreground process if it fails + Start-Job -Name "WatchDirectory.ps1" { + try + { + # TODO: Handle additional Watch-Directory params, use param splattering? + + & "C:\tools\scripts\Watch-Directory.ps1" -Path "C:\src" -Destination "C:\inetpub\wwwroot" -ExcludeFiles "Web.config" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } + } | ForEach-Object { + Write-Host ("### Started '$($_.Name)'.") + } +} +else +{ + Write-Host ("### Skipping start of 'WatchDirectory.ps1', to enable you should mount a directory into 'C:\src'.") +} + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config new file mode 100644 index 000000000..47b1e66a9 --- /dev/null +++ b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/EnableUdpLogging.config @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Production.ps1 b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Production.ps1 new file mode 100644 index 000000000..7daaad66b --- /dev/null +++ b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/Production.ps1 @@ -0,0 +1,122 @@ +# setup +$ErrorActionPreference = "STOP" + +Import-Module WebAdministration + +function Wait-WebItemState +{ + param( + [ValidateNotNullOrEmpty()] + [string]$IISPath + , + [ValidateSet("Started", "Stopped")] + [string]$State + ) + + while ($true) + { + Write-Host "### Waiting on item '$IISPath' state to be '$State'..." + + try + { + $item = Get-Item -Path $IISPath + + if ($null -ne $item -and $item.State -ne $State) + { + if ($State -eq "Started") + { + $item = Start-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + elseif ($State -eq "Stopped") + { + $item = Stop-WebItem -PSPath $IISPath -Passthru -ErrorAction "SilentlyContinue" + } + } + } + catch + { + $item = $null + } + + if ($null -ne $item -and $item.State -eq $State) + { + Write-Host "### Waiting on item '$IISPath' completed." + + break + } + + Start-Sleep -Milliseconds 500 + } +} + +# print start message +Write-Host ("### Sitecore Production ENTRYPOINT, starting...") + +# wait for w3wp to stop +while ($true) +{ + $processName = "w3wp" + + Write-Host "### Waiting for process '$processName' to stop..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -gt 0 + + if ($running) + { + Stop-Process -Name $processName -Force -ErrorAction "SilentlyContinue" + } + else + { + Write-Host "### Process '$processName' stopped..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to stop +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Stopped" + +# inject Sitecore config files +Copy-Item -Path (Join-Path $PSScriptRoot "\*.config") -Destination "C:\inetpub\wwwroot\App_Config\Include" + +# start ServiceMonitor.exe in background, kill foreground process if it fails +Start-Job -Name "ServiceMonitor.exe" { + try + { + & "C:\ServiceMonitor.exe" "w3svc" + } + finally + { + Get-Process -Name "filebeat" | Stop-Process -Force + } +} | Out-Null + +# wait for the ServiceMonitor.exe process is running +while ($true) +{ + $processName = "ServiceMonitor" + + Write-Host "### Waiting for process '$processName' to start..." + + $running = [array](Get-Process -Name $processName -ErrorAction "SilentlyContinue").Length -eq 1 + + if ($running) + { + Write-Host "### Process '$processName' started..." + + break; + } + + Start-Sleep -Milliseconds 500 +} + +# wait for application pool to start +Wait-WebItemState -IISPath "IIS:\AppPools\DefaultAppPool" -State "Started" + +# print ready message +Write-Host ("### Sitecore ready!") + +# start filebeat.exe in foreground +& "C:\tools\bin\filebeat\filebeat.exe" -c (Join-Path $PSScriptRoot "\filebeat.yml") \ No newline at end of file diff --git a/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/filebeat.yml b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/filebeat.yml new file mode 100644 index 000000000..b66525024 --- /dev/null +++ b/windows/9.2.0/sitecore-assets/tools/entrypoints/iis/filebeat.yml @@ -0,0 +1,19 @@ +filebeat.modules: +- module: iis + access: + enabled: ${ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED:false} + var.paths: ["C:/inetpub/logs/LogFiles/*/*.log"] + error: + enabled: ${ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED:false} + var.paths: ["C:/Windows/System32/LogFiles/HTTPERR/*.log"] + +filebeat.inputs: +- type: udp + enabled: ${ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED:true} + max_message_size: 100KiB + host: "127.0.0.1:7777" + +output.console: + pretty: true + codec.format: + string: '%{[message]}' \ No newline at end of file diff --git a/windows/tests/9.x.x/docker-compose.xm.yml b/windows/tests/9.x.x/docker-compose.xm.yml index 3cdbfee8a..777901397 100644 --- a/windows/tests/9.x.x/docker-compose.xm.yml +++ b/windows/tests/9.x.x/docker-compose.xm.yml @@ -20,9 +20,13 @@ services: cd: image: ${REGISTRY}sitecore-xm-cd:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} + entrypoint: powershell.exe -NoLogo -NoProfile -File C:\\tools\\entrypoints\\iis\\Development.ps1 + environment: + - "ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED=true" + - "ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED=true" + - "ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED=true" volumes: - ${LICENSE_PATH}:C:\license - - .\data\cd:C:\inetpub\wwwroot\App_Data\logs ports: - "44002:80" links: @@ -31,9 +35,13 @@ services: cm: image: ${REGISTRY}sitecore-xm-cm:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} + entrypoint: powershell.exe -NoLogo -NoProfile -File C:\\tools\\entrypoints\\iis\\Development.ps1 + environment: + - "ENTRYPOINT_STDOUT_IIS_ACCESS_LOG_ENABLED=false" + - "ENTRYPOINT_STDOUT_IIS_ERROR_LOG_ENABLED=false" + - "ENTRYPOINT_STDOUT_SITECORE_LOG_ENABLED=true" volumes: - ${LICENSE_PATH}:C:\license - - .\data\cm:C:\inetpub\wwwroot\App_Data\logs ports: - "44001:80" links: diff --git a/windows/tests/9.x.x/docker-compose.xp.spe.yml b/windows/tests/9.x.x/docker-compose.xp.spe.yml index 24becbc15..44ace95b4 100644 --- a/windows/tests/9.x.x/docker-compose.xp.spe.yml +++ b/windows/tests/9.x.x/docker-compose.xp.spe.yml @@ -21,7 +21,7 @@ services: xconnect: image: ${REGISTRY}sitecore-xp-xconnect:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect:C:\inetpub\wwwroot\App_Data\logs mem_limit: 1GB links: @@ -31,7 +31,7 @@ services: xconnect-automationengine: image: ${REGISTRY}sitecore-xp-xconnect-automationengine:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect-automationengine:C:\AutomationEngine\App_Data\logs mem_limit: 500MB links: @@ -41,7 +41,7 @@ services: xconnect-indexworker: image: ${REGISTRY}sitecore-xp-xconnect-indexworker:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect-indexworker:C:\IndexWorker\App_Data\logs mem_limit: 500MB links: diff --git a/windows/tests/9.x.x/docker-compose.xp.sxa.yml b/windows/tests/9.x.x/docker-compose.xp.sxa.yml index 91e16e241..8166f138b 100644 --- a/windows/tests/9.x.x/docker-compose.xp.sxa.yml +++ b/windows/tests/9.x.x/docker-compose.xp.sxa.yml @@ -21,7 +21,7 @@ services: xconnect: image: ${REGISTRY}sitecore-xp-xconnect:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect:C:\inetpub\wwwroot\App_Data\logs mem_limit: 1GB links: @@ -31,7 +31,7 @@ services: xconnect-automationengine: image: ${REGISTRY}sitecore-xp-xconnect-automationengine:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect-automationengine:C:\AutomationEngine\App_Data\logs mem_limit: 500MB links: @@ -41,7 +41,7 @@ services: xconnect-indexworker: image: ${REGISTRY}sitecore-xp-xconnect-indexworker:${SITECORE_VERSION}-windowsservercore-${WINDOWSSERVERCORE_VERSION} volumes: - - C:\license:C:\license + - ${LICENSE_PATH}:C:\license - .\data\xconnect-indexworker:C:\IndexWorker\App_Data\logs mem_limit: 500MB links: