Module/ContainerHandling/New-BCSDevContainer.ps1
<#
.SYNOPSIS Creates a new local dev container .DESCRIPTION Create a new dev container and publish apps based on settings in pipeline buildsettings.json. .PARAMETER containerName Name of the new Container (if the container already exists it will be replaced) .PARAMETER memoryLimit Memory limit for the container (default is unlimited for process isolation and 8G for hyperv isolation containers), defaults to 6G .PARAMETER licenseFile Path or Secure Url of the licenseFile you want to use, defaults to https://brightcomdevops.blob.core.windows.net/devops/5538404.flf .PARAMETER BuildSettingsFolder Path to pipeline buildsettings.json, usually in repository sub folder .azureDevOps .PARAMETER credential Username and Password for the Container .PARAMETER artifactUrl Url for application artifact to use. If you also specify an ImageName, an image will be build (if it doesn't exist) using these artifacts and that will be run. .EXAMPLE $Password = ConvertTo-SecureString -String "P@ssword" -AsPlainText -Force $Credential = New-Object System.Management.Automation.PSCredential -argumentList "admin", $securePassword $Artifact = Get-BCArtifactUrl -type OnPrem -country se -version 17 -select Latest New-BCSDevContainer -ContainerName 'desenio', -BuildSettingsFolder 'C:\BrightCom\DevOps\Brightcom Solutions\Desenio\Desenio\.azureDevOps' -credential $Credential -artifactUrl $Artifact .NOTES Author: Mathias Stjernfelt Website: http://www.brightcom.se #> function New-BCSDevContainer { Param ( [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$ContainerName, [Parameter(ValueFromPipelineByPropertyName, Mandatory = $false)] [string]$memoryLimit = '6G', [Parameter(ValueFromPipelineByPropertyName, Mandatory = $false)] [string]$licenseFile = 'https://brightcomdevops.blob.core.windows.net/devops/5538404.flf', [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$BuildSettingsFolder, [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [PSCredential]$credential, [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)] [string]$artifactUrl ) begin { $version = GetVersionFromArtifactURL([uri]$Script:gConfig.ArtifactURL); if (-not [string]::IsNullOrEmpty($version)) { $major = $version.Split('.'); } else { $major = 14; } } process { if ([int]$major[0] -gt 14) { New-BcContainer -accept_eula ` -artifactUrl $artifactUrl ` -Credential $credential ` -accept_outdated ` -isolation process ` -containerName $ContainerName ` -licenseFile $licenseFile ` -memoryLimit $memoryLimit ` -shortcuts StartMenu ` -includeAL ` -useBestContainerOS ` -auth UserPassword ` -updateHosts ` -enableTaskScheduler } else { New-BcContainer -accept_eula ` -artifactUrl $artifactUrl ` -Credential $credential ` -accept_outdated ` -isolation process ` -containerName $ContainerName ` -licenseFile $licenseFile ` -memoryLimit $memoryLimit ` -shortcuts StartMenu ` -includeAL ` -useBestContainerOS ` -auth UserPassword ` -updateHosts ` -enableSymbolLoading ` -IncludeCSide ` -enableTaskScheduler } $settings = (Get-Content ((Get-ChildItem -Path $BuildSettingsFolder -Filter "build-settings.json" -Recurse).FullName) -Encoding UTF8 | Out-String | ConvertFrom-Json) $settings.dependencies | ForEach-Object { Write-Host "Publishing $_" Publish-BCContainerApp -containerName $ContainerName -appFile $_ -skipVerification -sync -install } } end { } } Export-ModuleMember -Function New-BCSDevContainer |