Docker Deployment

Prerequisite

Windows VM running Docker for Windows

To access https://gitlab.com/cinchy/cinchy/container_registry, please reach out to your Customer Success contact or email support@cinchy.com

Setup

Save the following setup.ps1 to the machine running Docker

setup.ps1
param(
[String]$rootDirectory = $null,
[String]$rootLogDirectory = $null,
[String]$domain = $null,
[String]$connectionString = $null,
[Int]$port = $null,
[Int]$containerPort = $null
)
<#
Parameter Examples:
[String]$rootDirectory = "C:\",
[String]$rootLogDirectory = "C:\CinchyLogs",
[String]$domain = "localhost",
[String]$connectionString = "Server=$dbServer;Database=$database;Trusted_Connection=False;Connection Timeout=30;Min Pool Size=10;User Id=$connectionID;Password=$connectionPass",
[Int]$port = $null,
[Int]$containerPort = $null
#>
$params = @(
$rootDirectory, $rootLogDirectory, $domain, $port, $containerPort, $connectionString
)
foreach ($param in $params){
if ($param -eq ""){
Write-Host "Null value detected, Script Stopped"
exit $LASTEXITCODE
}
}
if (-not (Test-Path "$rootDirectory\Cinchy") -or -not(Test-Path "$rootDirectory\CinchySSO")){
Write-Host "Root directory does not contain Cinchy or CinchySSO"
exit $LASTEXITCODE
}
#replace values in C:\Cinchy\web.config
$replaceWebLog = "$rootLogDirectory\Cinchy\log.txt"
$replaceWebAuthority = "http://${domain}:$port/CinchySSO"
$replaceWebRedirect = "http://${domain}:$port/Cinchy/Account/LoginRedirect"
$webRootFolder = "$rootDirectory\Cinchy"
$webConfig = "$webRootFolder\web.config"
#replace values in C:\CinchySSO\log4net.config
$replaceSSOLog = "$rootLogDirectory\CinchySSO\log.txt"
#login redirect is supposed to be identical to redirect from web.config
$replaceSSOLogin = $replaceWebRedirect
$replaceSSOLogout = "http://${domain}:$port/Cinchy"
$ssoRootFolder = "$rootDirectory\CinchySSO"
$ssoCertDirectory = "$rootDirectory\CinchySSO\cinchyidentitysrv.pfx"
$ssoCert = $ssoCertDirectory -replace "\\", "\\"
$appSettings = "$ssoRootFolder\appsettings.json"
$appLogPath = "$ssoRootFolder\log4net.config"
$regex = '(?<=<add key="SSOLogPath" value=")[^"]*'
(Get-Content $webConfig) -replace $regex, ${replaceWebLog} | Set-Content $webConfig
$regex = '(?<=<add key="StsAuthorityUri" value=")[^"]*'
(Get-Content $webConfig) -replace $regex, ${replaceWebAuthority} | Set-Content $webConfig
$regex = '(?<=<add key="StsRedirectUri" value=")[^"]*'
(Get-Content $webConfig) -replace $regex, ${replaceWebRedirect} | Set-Content $webConfig
(Get-Content $webConfig).replace('#', '-') | Set-Content $webConfig
#transform appsettings.json
$regex = '(?<="CinchyLoginRedirectUri": ")[^"]*'
(Get-Content $appSettings) -replace $regex, ${replaceSSOLogin} | Set-Content $appSettings
$regex = '(?<="CinchyPostLogoutRedirectUri": ")[^"]*'
(Get-Content $appSettings) -replace $regex, ${replaceSSOLogout} | Set-Content $appSettings
$regex = '(?<="CertificatePath": ")[^"]*'
(Get-Content $appSettings) -replace $regex, ${ssoCert} | Set-Content $appSettings
#transform connection string in web.config and appsettings.json
$regex = '(?<=<add name="SqlServer" connectionString=")[^"]*'
(Get-Content $webConfig) -replace $regex, ${connectionString} | Set-Content $webConfig
$regex = '(?<="SqlServer": ")[^"]*'
(Get-Content $appSettings) -replace $regex, ${connectionString} | Set-Content $appSettings
$regex = '(?<=<file value=")[^"]*'
(Get-Content $appLogPath) -replace $regex, ${replaceSSOLog} | Set-Content $appLogPath
if(Get-WebApplication "Cinchy")
{
Remove-WebApplication -Name "Cinchy" -Site "Default Web Site"
}
if(Get-WebApplication "CinchySSO")
{
Remove-WebApplication -Name "CinchySSO" -Site "Default Web Site"
}
if(Get-IISAppPool "Cinchy")
{
Remove-WebAppPool "Cinchy"
}
if(Get-IISAppPool "CinchySSO")
{
Remove-WebAppPool "CinchySSO"
}
Start-Sleep -s 2
Set-WebBinding -Name 'Default Web Site' -BindingInformation "*:8080:" -PropertyName Port -Value ${containerPort}
Start-Sleep -s 2
New-WebAppPool -name Cinchy
New-WebAppPool -name CinchySSO
Set-ItemProperty -Path IIS:\AppPools\CinchySSO -Name managedRuntimeVersion ""
New-WebApplication -Name Cinchy -site 'Default Web Site' -PhysicalPath "${rootDirectory}\Cinchy" -ApplicationPool Cinchy
New-WebApplication -Name CinchySSO -site 'Default Web Site' -PhysicalPath "${rootDirectory}\CinchySSO" -ApplicationPool CinchySSO
exit $LASTEXITCODE

How to run Cinchy Docker

# pull Cinchy
docker pull registry.gitlab.com/cinchy/cinchy:4.3.0
# run the container from the image, this is running on port 8000 for the host and 8080 on the container
docker run -d -p 8000:8080 --name <ContainerName> <ImageID or Name>
docker cp <Path to setup.ps1 script> <ContainerName>:C:\
# connect to container to run the configuration script
docker exec -i <ContainerName> powerShell
Inside the container:
PS C:\>.\setup.ps1 <Parameters>
Parameters:
$rootDirectory : <String> Path to directory where Cinchy and CinchySSO
directories are located
$rootLogDirectory : <String> Path to directory CinchyLogs
$connectionString : <String> SQL Server auto generated from above parameters
Can be replaced with any connection string to
Supported database
$port : <Int> port that the container is running on host
$containerPort : <Int> port that the container using
# example powershell line for creating a local instance of Cinchy running on port 8000
PS C:\>.\setup.ps1 -rootDirectory "C:" -rootLogDirectory "C:\CinchyLogs" -connectionString "<your database server>;Database=Cinchy;Trusted_Connection=False;Connection Timeout=30;Min Pool Size=10;User Id=cinchy;Password=cinchy” -domain "<your server url>" -port "8000"