Skip to content

Commit

Permalink
Build improvements (#19)
Browse files Browse the repository at this point in the history
* Build: build script copies inrule assets from default install folder (param).

* Docs: update README for build script changes

* Build: add automated version location and setting for image assets

* Build: add support for should process

* Docs: change samples to point at hub images. title formatting consistency fix

* Build: re-add missing flag for server build skipping

* Docs: Change references to previous image repos

* Build: lower risk of bungled builds by cleaning directories before file copy
  • Loading branch information
jelster authored Mar 22, 2018
1 parent a0f8e3b commit 73b8bc6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 45 deletions.
63 changes: 43 additions & 20 deletions Developer Samples/WindowsContainers/build.ps1
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[string]$tag,
[string]$registryRootRepos = "inrule",
[switch]$setLatestTag = $false,
[switch]$skipServerBuild = $false
[switch]$skipServerBuild = $false,
[string]$defaultInRuleInstallFolder = "C:\Program Files (x86)\InRule\"
)
Push-Location $PSScriptRoot

$version = $null
if ($tag -ne "latest") {
$version = $tag
Write-Host "Attempting to determine the version number for assets located at $defaultInRuleInstallFolder"
$version = (Get-ChildItem $defaultInRuleInstallFolder\*\InRule.Common.dll -recurse)[0].VersionInfo.ProductVersion
Write-Host "Using InRule version $version"

if (([String]::IsNullOrWhiteSpace($tag) -and ($null -ne $version))) {
Write-Host "No value supplied for image tag. Using $version for tagging images."
$tag = $version
}
$ErrorActionPreference = "Stop"
Write-Host "Images will be tagged $tag. Also tag them as latest? $setLatestTag"

if ($skipServerBuild -eq $false) {
$ErrorActionPreference = "Stop"
if ($skipServerBuild -eq $false) {
write-host "Building inrule-server base image."
set-location "$PSScriptRoot\inrule-server"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-server:$tag .
if ($setLatestTag -eq $true ) {
write-host "Setting image $version to latest..."
docker image tag ${registryRootRepos}/inrule-server:$tag ${registryRootRepos}/inrule-server:latest
if ($PSCmdlet.ShouldProcess("Building inrule-server base image")) {
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-server:$tag .
}
if ($setLatestTag -eq $true -and $PSCmdlet.ShouldProcess("Setting image $version to latest...")) {
docker image tag ${registryRootRepos}/inrule-server:$tag ${registryRootRepos}/inrule-server:latest
}
}

Write-Host "Building inrule-catalog image."
set-location "$PSScriptRoot\inrule-catalog"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-catalog:$tag .
$hostCatalogPath = resolve-path "$defaultInRuleInstallFolder\irServer\RepositoryService\IisService\"
$catalogBuildPath = "$PSScriptRoot\inrule-catalog"
set-location $catalogBuildPath
if ($PSCmdlet.ShouldProcess("Building inrule-catalog image using assets at $hostCatalogPath")) {
Remove-Item -Path $catalogBuildPath\irCatalog\ -Include *.* -Recurse -Force
Copy-Item $hostCatalogPath\** -Recurse -Force -Destination "$catalogBuildPath\irCatalog\"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-catalog:$tag .
}

write-host "Building inrule-runtime image."
set-location "$PSScriptRoot\inrule-runtime"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-runtime:$tag .
$hostRuntimePath = resolve-path $defaultInRuleInstallFolder\irServer\RuleEngineService\IisService
$runtimeBuildPath = "$PSScriptRoot\inrule-runtime"
set-location $runtimeBuildPath
if ($PSCmdlet.ShouldProcess("Building inrule-runtime image using assets at $hostRuntimePath")) {
Remove-Item -Path $runtimeBuildPath\irServer\ -Include *.* -Recurse -Force
Copy-Item -Path $hostRuntimePath\** -Recurse -Force -Destination "$runtimeBuildPath\irServer"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-runtime:$tag .
}

write-host "Building inrule-catalog-manager image."
set-location "$PSScriptRoot\inrule-catalog-manager"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-catalog-manager:$tag .
$hostCatManPath = resolve-path $defaultInRuleInstallFolder\irServer\CatalogManagerWeb
$catmanBuildPath = "$PSScriptRoot\inrule-catalog-manager"
set-location $catmanBuildPath
if ($PSCmdlet.ShouldProcess("Building inrule-catalog-manager image using assets at $hostCatManPath")) {
Remove-Item -Path $catmanBuildPath\CatalogManagerWeb -Include *.* -Recurse -Force
Copy-Item -Path $hostCatManPath\** -Recurse -Force -Destination "$catmanBuildPath\CatalogManagerWeb"
docker build --label "com.inrule.version=$version" -t ${registryRootRepos}/inrule-catalog-manager:$tag .
}

if ($setLatestTag -eq $true ) {
write-host "Setting image $version to latest..."
if ($setLatestTag -eq $true -and $PSCmdlet.ShouldProcess("Setting image $tag to latest...") ) {
docker image tag ${registryRootRepos}/inrule-catalog:$tag ${registryRootRepos}/inrule-catalog:latest

docker image tag ${registryRootRepos}/inrule-runtime:$tag ${registryRootRepos}/inrule-runtime:latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# InRule Samples

## Sample Title

# README for Web Catalog Manager DOCKERFILE
## README for Web Catalog Manager DOCKERFILE

## Important notes on building the image

Expand All @@ -25,15 +23,15 @@ Typically, there's no need to modify this value in your builds.

```cmd
docker build -t server/inrule-catalog-manager:5.0.14 .
docker build -t inrule/inrule-catalog-manager:5.0.14 .
```

#### Specifying an alternative path for source artifacts

```cmd
docker build --build-arg catManDir=c:\users\jsmith\downloads\irServer -t server/inrule-catalog-manager:5.0.12 .
docker build --build-arg catManDir=c:\users\jsmith\downloads\irServer -t inrule/inrule-catalog-manager:5.0.12 .
```

Expand All @@ -45,7 +43,7 @@ Once started, you can open a web browser and navigate to the IP address of the c

```cmd
docker run server/inrule-catalog-manager:latest
docker run inrule/inrule-catalog-manager:latest
```

Expand All @@ -55,6 +53,6 @@ This will start a container running the Web Catalog Manager site using the defau

```cmd
docker run -d --env CatalogUri=https://acme-catalog.cloudapp.net/Service.svc server/inrule-catalog-manager:latest
docker run -d --env CatalogUri=https://acme-catalog.cloudapp.net/Service.svc inrule/inrule-catalog-manager:latest
```
8 changes: 3 additions & 5 deletions Developer Samples/WindowsContainers/inrule-catalog/readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# InRule Samples

## Windows Containers

This README describes the irCatalog Docker file.
## README for the irCatalog Docker file

### Important notes on building the image

Expand Down Expand Up @@ -36,12 +34,12 @@ The `-v` option tells Docker to mount the contents of the given host directory -

You can build this image from source using a command similar to the following example:

`docker build -t server/inrule-catalog:5.0.26 .`
`docker build -t inrule/inrule-catalog:5.0.26 .`

### Running the image

Place the `InRuleLicense.xml` file in a location where the IIS process inside the docker container will be able to read it (e.g. not under a user's home directory)

`docker run -d --name cat -e CatalogUser=sa -e CatalogPassword=<SA_PASSWORD> -e CatalogDbHost=<DB_HOST> -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' server/inrule-catalog:latest`
`docker run -d --name cat -e CatalogUser=sa -e CatalogPassword=<SA_PASSWORD> -e CatalogDbHost=<DB_HOST> -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' inrule/inrule-catalog:latest`

When running this image, you'll need to supply all required and any optional environment parameters.
16 changes: 7 additions & 9 deletions Developer Samples/WindowsContainers/inrule-runtime/readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# InRule Samples

## Sample Title

# README for the inrule-runtime DOCKER image
## README for the inrule-runtime DOCKER image

## Important notes on building the image

Expand All @@ -22,11 +20,11 @@

#### Using defaults

```docker build -t server/inrule-runtime:5.0.26 .```
```docker build -t inrule/inrule-runtime:5.0.26 .```

#### Specifying an alternative path for source artifacts

```docker build --build-arg irRuntimeDir=c:\users\jsmith\downloads\irServer -t server/inrule-runtime:5.0.12 .```
```docker build --build-arg irRuntimeDir=c:\users\jsmith\downloads\irServer -t inrule/inrule-runtime:5.0.12 .```

## Running the image

Expand All @@ -41,31 +39,31 @@ Place the `InRuleLicense.xml` file in a location where the IIS process inside th

```cmd
docker run -d -p 80:80 --env CatalogUri='https://contoso-catalog.cloudapp.net/Service.svc' -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' server/inrule-runtime:latest
docker run -d -p 80:80 --env CatalogUri='https://contoso-catalog.cloudapp.net/Service.svc' -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' inrule/inrule-runtime:latest
```

### Basic usage connecting to a linked container catalog

```cmd
docker run -d --link cat --env CatalogUri='https://cat/Service.svc' -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' server/inrule-runtime:latest
docker run -d --link cat --env CatalogUri='https://cat/Service.svc' -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' inrule/inrule-runtime:latest
```

Using a volume mount for file-based ruleapps and a container link to a container running irCatalog:

```cmd
docker run -d --rm --name=rex -v c:\inrule-ruleapps\:c:\RuleApps\ -P --link=cat -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' server/inrule-runtime:latest
docker run -d --rm --name=rex -v c:\inrule-ruleapps\:c:\RuleApps\ -P --link=cat -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' inrule/inrule-runtime:latest
```

Using a volume mount for endpoint assemblies and a container link to a container running irCatalog:

```cmd
docker run -d --rm --name=rex -v c:\inrule-assemblies\:c:\inrule-runtime\bin\EndpointAssemblies\ -P --link=cat -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' server/inrule-runtime:latest
docker run -d --rm --name=rex -v c:\inrule-assemblies\:c:\inrule-runtime\bin\EndpointAssemblies\ -P --link=cat -v '<HOST_LICENSE_DIRECTORY>:C:\ProgramData\InRule\SharedLicenses:ro' inrule/inrule-runtime:latest
```

Expand Down
8 changes: 4 additions & 4 deletions Developer Samples/WindowsContainers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ If you want to also have the images tagged as 'latest', pass `-SetLatestTag` to

`.\build.ps1 -tag '5.0.24' -setLatestTag`

To skip building the `inrule-server` base image, pass the `skipServerBuild` switch to the build script.

<!-- Unless otherwise specified, InRule assets (e.g., irCatalog, irServer components) will be copied into their respective directories by the build script. The default installation location of `C:\Program Files (x86)\InRule\irServer` is used for this, but can be overridden by providing a value for the `defaultInRuleInstallFolder` parameter:
Unless otherwise specified, InRule assets (e.g., irCatalog, irServer components) will be copied into their respective directories by the build script. The default installation location of `C:\Program Files (x86)\InRule\irServer` is used for this, but can be overridden by providing a value for the `defaultInRuleInstallFolder` parameter:

`.\build.ps1 -tag '5.0.26 -defaultInRuleInstallFolder 'z:\inrule\'`
-->

To skip building the `inrule-server` base image, pass the `skipServerBuild` switch to the build script.

<!-- For instructions on building a set of images using Compose, see the section below on **Using Docker Compose to provision a rule execution environment** -->
Please see the instructions for each respective image for information on how to build the individual images.

Expand Down

0 comments on commit 73b8bc6

Please sign in to comment.