-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
executable file
·31 lines (25 loc) · 1.1 KB
/
build.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
#!/usr/bin/env pwsh
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
# Get component metadata and set necessary variables
$component = Get-Content -Path "$PSScriptRoot/component.json" | ConvertFrom-Json
$buildImage = "$($component.registry)/$($component.name):$($component.version)-$($component.build)-build"
$container = $component.name
# Remove build files
if (Test-Path -Path "$PSScriptRoot/obj") {
Remove-Item -Recurse -Force -Path "$PSScriptRoot/obj"
}
if (Test-Path -Path "$PSScriptRoot/lib") {
Remove-Item -Recurse -Force -Path "$PSScriptRoot/lib"
}
# Build docker image
docker build -f "$PSScriptRoot/docker/Dockerfile.build" -t $buildImage .
# Create and copy compiled files, then destroy
docker create --name $container $buildImage
docker cp "$($container):/app/obj" "$PSScriptRoot/obj"
docker cp "$($container):/app/lib" "$PSScriptRoot/lib"
docker rm $container
# Verify build
if (-not (Test-Path -Path "$PSScriptRoot/obj") -or -not (Test-Path -Path "$PSScriptRoot/lib")) {
Write-Error "obj or lib folder doesn't exists in root dir. Build failed. See logs above for more information."
}