Last active
July 21, 2017 20:20
-
-
Save jelster/bfdc02947dbdf25513fb956c56d49e03 to your computer and use it in GitHub Desktop.
Containerizing the InRule Stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# escape=` | |
FROM microsoft/windowsservercore:latest | |
SHELL ["powershell", "-Command"] | |
ADD . c:\temp\ | |
WORKDIR c:\temp\ | |
RUN .\InRuleServerDSC.ps1 -Wait; | |
COPY [".\\InRuleLicense.xml", "C:\\Program Data\\InRule\\Shared Licenses"] | |
# REMARK: Temporary workaround for Windows DNS client weirdness | |
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord | |
RUN Import-Module "WebAdministration" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration Website | |
{ | |
param ($MachineName = "localhost") | |
Node ($MachineName) | |
{ | |
WindowsFeature WebServerRole | |
{ | |
Name = "Web-Server" | |
Ensure = "Present" | |
} | |
WindowsFeature WebAspNet45 | |
{ | |
Name = "Web-Asp-Net45" | |
Ensure = "Present" | |
DependsOn = "[WindowsFeature]WebServerRole" | |
} | |
WindowsFeature WCFServices45 | |
{ | |
Name = "Net-WCF-Services45" | |
Ensure = "Present" | |
DependsOn = "[WindowsFeature]WebAspNet45" | |
} | |
WindowsFeature WCFHttpActivation | |
{ | |
Name = "Net-WCF-Http-Activation45" | |
Ensure = "Present" | |
DependsOn = "[WindowsFeature]WCFServices45" | |
} | |
WindowsFeature WCFTCPPortSharing | |
{ | |
Name = "Net-WCF-TCP-PortSharing45" | |
Ensure = "Present" | |
DependsOn = "[WindowsFeature]WCFHttpActivation" | |
} | |
Script CreateInRuleEventSource | |
{ | |
GetScript = { @{ Result=""}} | |
TestScript = { $false } | |
SetScript = { | |
New-EventLog -LogName Application -Source InRule | |
} | |
} | |
} | |
} | |
Website -MachineName localhost | |
Start-DscConfiguration -Path .\Website -Wait -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# escape=` | |
FROM <sample registry image of base server> | |
ENV CatalogUri="http://cat/InRuleCatalogService/Service.svc" ` | |
irRuntimeDir="C:\InRule" | |
EXPOSE 80:80 | |
EXPOSE 443:443 | |
WORKDIR C:\temp | |
# COPY or ADD the irServer WCF artifacts into the container at c:\inrule | |
RUN Start-IISCommitDelay -Verbose; ` | |
(Get-IISSite -name 'Default Web Site').Applications.Add('/InRuleRuleEngineService', $env:irRuntimeDir); ` | |
Stop-IISCommitDelay -Verbose; | |
COPY *.ps1 C:\temp\ | |
CMD ["powershell", "-command ./Start -Verbose"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$installPath = $env:irCatalogDir | |
write-verbose "Looking for web.config located at $installPath" | |
write-verbose "CatalogURI set in config will be $env:CatalogUri" | |
.\Set-RuntimeConfig.ps1 -catalogServiceUri $env:CatalogUri -installPath $installPath -Verbose; | |
$lastCheck = (Get-Date).AddSeconds(-2) | |
while ($true) { | |
Get-EventLog -LogName Application -Source "InRule*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message | |
$lastCheck = Get-Date | |
Start-Sleep -Seconds 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param( | |
[string]$catalogUser = "Admin", | |
[string]$catalogPass = "password", | |
[string]$installPath = "C:\Program Files (x86)\InRule\irServer\RuleEngineService\IisService\", | |
[string]$restRuleApplication = "C:\RuleApps", | |
[string]$catalogServiceUri = "http://localhost/InRuleCatalogService/Service.svc", | |
[string]$endpointAssemblyPath | |
) | |
write-host "Replacing supplied configuration values in web.config..." | |
$configFilePath = resolve-Path -Path (Join-Path -Path $installPath -ChildPath "Web.config") | |
if ((test-path $installPath) -eq $false) { | |
throw "cannot find path to service configuration file."; | |
return -1; | |
} | |
$cfgXml = new-object Xml | |
$cfgXml.LoadXml((gc $configFilePath)) | |
$catSvc = $cfgXml.configuration.'inrule.runtime.service'.catalog | |
if ($catSvc -eq $null) { | |
write-error "Could not locate configuration section inrule.repository.service.connectionString. irCatalog is unlikely to function in this state." | |
$catSvc = $cfgXml.CreateElement("catalog") | |
$cfgXml.configuration.'inrule.runtime.service'.appendChild($catSvc) | |
write-verbose "Added connectionString node to 'inrule.repository.service'" | |
} | |
$catSvc.SetAttribute("catalogServiceUri", $catalogServiceUri) | |
$catSvc.SetAttribute("userName", "") | |
$catSvc.SetAttribute("password", "") | |
if ($endpointAssemblyPath -ne $null -and $endpointAssemblyPath -ne "") { | |
write-verbose "Setting endpointAssemblyPath to $endpointAssemblyPath in config" | |
$cfgXml.configuration.'inrule.repository'.endPoints.assemblyEndpoint.SetAttribute("endpointAssemblyPath", $endpointAssemblyPath) | |
} | |
if ($PSCmdlet.ShouldProcess("Save configuration string changes to config")) { | |
$cfgXml.Save($configFilePath) | |
} | |
write-host "Saved configuration changes." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
of course, there's room for exploration here. If we are OK mounting the configuration file in a shared volume, for instance, we could omit much of these scripts. That has the drawback though of becoming a potential scaling bottleneck since a swarm would be forced to share config values for things that might need to be container-specific.