-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.ps1
executable file
·42 lines (34 loc) · 1.28 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Powershell
<# Copyright (c) 2022 IAR Systems AB
#
# run.ps1 - Run a container with the IAR Build Tools
#
# See LICENSE for detailed license information
#>
param(
[parameter(Mandatory=$true)]
# iarsystems/bx<package>:<version>
[String]${PkgNameVersion}
)
${ScriptPath} = Split-Path $PSCommandPath -Parent
${PkgName} = ${PkgNameVersion}.Split("/")[-1].Split(":")[0]
${PkgVersion} = ${PkgNameVersion}.Split(":")[-1]
${DockerImageList} = docker images --filter reference=iarsystems/${PkgName}":"${PkgVersion} -q --format "{{.Repository}}:{{.Tag}}"
Write-Output ${DockerImageList}
if (${DockerImageList} -eq $null) {
Write-Output "ERROR: image ${PkgName}`:${PkgVersion} not found."
}
Write-Output "-- Running a Docker container for ${PkgName}-${PkgVersion}..."
$CurrentLocation = Get-Location
$ContainerID = docker run --detach `
--hostname $env:ComputerName `
--tty `
--volume LMS2`:/usr/local/etc/IARSystems `
--volume $CurrentLocation`:/build `
${PkgNameVersion}
Write-Output "-- The working directory is $CurrentLocation."
Write-Output " "
$ImageAliases = "${ScriptPath}\aliases-set.ps1"
$args = @()
$args += $ContainerID
Invoke-Expression "$ImageAliases $args"