Skip to content

Commit a45c6de

Browse files
Update build and packaging for Alpine (#19)
1 parent 4dfff73 commit a45c6de

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

.vsts-ci/linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ phases:
2020
buildName: ubuntu.16.04
2121
Linux Native:
2222
buildName: centos.7
23+
Linux Alpine:
24+
buildName: alpine
2325

2426
steps:
2527
- powershell: |

build.psm1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function Get-EnvironmentInformation
144144
$environment += @{'IsOpenSUSE42.1' = $Environment.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '42.1'}
145145
$environment += @{'IsRedHatFamily' = $Environment.IsCentOS -or $Environment.IsFedora}
146146
$environment += @{'IsSUSEFamily' = $Environment.IsSLES -or $Environment.IsOpenSUSE}
147+
$environment += @{'IsAlpine' = $LinuxInfo.ID -match 'alpine'}
147148

148149
# Workaround for temporary LD_LIBRARY_PATH hack for Fedora 24
149150
# https://github.com/PowerShell/PowerShell/issues/2511
@@ -491,6 +492,10 @@ function Start-BuildPowerShellNativePackage
491492
[ValidateScript({Test-Path $_ -PathType Leaf})]
492493
[string] $LinuxARMZipPath,
493494

495+
[Parameter(Mandatory = $true)]
496+
[ValidateScript({Test-Path $_ -PathType Leaf})]
497+
[string] $LinuxAlpineZipPath,
498+
494499
[Parameter(Mandatory = $true)]
495500
[ValidateScript({Test-Path $_ -PathType Leaf})]
496501
[string] $macOSZipPath,
@@ -520,6 +525,7 @@ function Start-BuildPowerShellNativePackage
520525
$BinFolderARM64 = Join-Path $tempExtractionPath "ARM64"
521526
$BinFolderLinux = Join-Path $tempExtractionPath "Linux"
522527
$BinFolderLinuxARM = Join-Path $tempExtractionPath "LinuxARM"
528+
$BinFolderLinuxAlpine = Join-Path $tempExtractionPath "LinuxAlpine"
523529
$BinFolderMacOS = Join-Path $tempExtractionPath "MacOS"
524530
$BinFolderPSRP = Join-Path $tempExtractionPath "PSRP"
525531

@@ -528,13 +534,14 @@ function Start-BuildPowerShellNativePackage
528534
Expand-Archive -Path $WindowsARMZipPath -DestinationPath $BinFolderARM -Force
529535
Expand-Archive -Path $WindowsARM64ZipPath -DestinationPath $BinFolderARM64 -Force
530536
Expand-Archive -Path $LinuxZipPath -DestinationPath $BinFolderLinux -Force
537+
Expand-Archive -Path $LinuxAlpineZipPath -DestinationPath $BinFolderLinuxAlpine -Force
531538
Expand-Archive -Path $LinuxARMZipPath -DestinationPath $BinFolderLinuxARM -Force
532539
Expand-Archive -Path $macOSZipPath -DestinationPath $BinFolderMacOS -Force
533540
Expand-Archive -Path $psrpZipPath -DestinationPath $BinFolderPSRP -Force
534541

535542
PlaceWindowsNativeBinaries -PackageRoot $PackageRoot -BinFolderX64 $BinFolderX64 -BinFolderX86 $BinFolderX86 -BinFolderARM $BinFolderARM -BinFolderARM64 $BinFolderARM64
536543

537-
PlaceUnixBinaries -PackageRoot $PackageRoot -BinFolderLinux $BinFolderLinux -BinFolderLinuxARM $BinFolderLinuxARM -BinFolderOSX $BinFolderMacOS -BinFolderPSRP $BinFolderPSRP
544+
PlaceUnixBinaries -PackageRoot $PackageRoot -BinFolderLinux $BinFolderLinux -BinFolderLinuxARM $BinFolderLinuxARM -BinFolderOSX $BinFolderMacOS -BinFolderPSRP $BinFolderPSRP -BinFolderLinuxAlpine $BinFolderLinuxAlpine
538545

539546
$Nuspec = @'
540547
<?xml version="1.0" encoding="utf-8"?>
@@ -599,6 +606,10 @@ function PlaceUnixBinaries
599606
[ValidateScript({Test-Path $_ -PathType Container})]
600607
$BinFolderLinuxARM,
601608

609+
[Parameter(Mandatory = $true)]
610+
[ValidateScript({Test-Path $_ -PathType Container})]
611+
$BinFolderLinuxAlpine,
612+
602613
[Parameter(Mandatory = $true)]
603614
[ValidateScript({Test-Path $_ -PathType Container})]
604615
$BinFolderOSX,
@@ -610,10 +621,12 @@ function PlaceUnixBinaries
610621

611622
$RuntimePathLinux = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-x64/native') -Force
612623
$RuntimePathLinuxARM = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-arm/native') -Force
624+
$RuntimePathLinuxAlpine = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-musl-x64/native') -Force
613625
$RuntimePathOSX = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/osx/native') -Force
614626

615627
Copy-Item "$BinFolderLinux\*" -Destination $RuntimePathLinux -Verbose
616628
Copy-Item "$BinFolderLinuxARM\*" -Destination $RuntimePathLinuxARM -Verbose
629+
Copy-Item "$BinFolderLinuxAlpine\*" -Destination $RuntimePathLinuxAlpine -Verbose
617630
Copy-Item "$BinFolderOSX\*" -Destination $RuntimePathOSX -Verbose
618631

619632
## LinuxARM is not supported by PSRP
@@ -1979,6 +1992,12 @@ function Start-PSBootstrap {
19791992

19801993
# Install patched version of curl
19811994
Start-NativeExecution { brew install curl --with-openssl --with-gssapi } -IgnoreExitcode
1995+
} elseif ($Environment.IsAlpine) {
1996+
$Deps += "build-base", "gcc", "abuild", "binutils", "git", "python", "bash", "cmake"
1997+
1998+
# Install dependencies
1999+
Start-NativeExecution { apk update }
2000+
Start-NativeExecution { apk add $Deps }
19822001
}
19832002

19842003
# Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn)

tools/releaseBuild/PowershellNative.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
param (
77

88
[Parameter(Mandatory, ParameterSetName = 'Build')]
9-
[ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm')]
9+
[ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm', 'linux-musl-x64')]
1010
[string]
1111
$Arch,
1212

@@ -31,7 +31,7 @@ end {
3131
$binOut = New-Item -Path $TargetLocation -ItemType Directory -Force
3232
Write-Verbose "Created output directory: $binOut" -Verbose
3333

34-
if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx') {
34+
if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx' -or $Arch -eq 'linux-musl-x64') {
3535

3636
Write-Verbose "Starting Build for: $Arch" -Verbose
3737

@@ -61,7 +61,6 @@ end {
6161
} else {
6262
Write-Verbose -Verbose "Skipping artifact upload since this is a PR."
6363
}
64-
6564
}
6665
else {
6766
Write-Verbose "Starting Start-PSBootstrap" -Verbose

tools/releaseBuild/build.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@
9797
"DockerImageName": "ps-centos-7",
9898
"BinaryBucket": "release",
9999
"EnableFeature": [ "ArtifactAsFolder" ]
100+
},
101+
{
102+
"Name": "alpine",
103+
"RepoDestinationPath": "/PowerShellNative",
104+
"BuildCommand": "/PowerShellNative/tools/releaseBuild/PowershellNative.ps1 -RepoRoot _RepoDestinationPath_ -TargetLocation _DockerVolume_ -Arch linux-musl-x64 -Configuration Release",
105+
"AdditionalContextFiles": [
106+
"./tools/releaseBuild/PowershellNative.ps1"
107+
],
108+
"DockerFile": "./tools/releaseBuild/images/Alpine/Dockerfile",
109+
"DockerImageName": "ps-alpine",
110+
"BinaryBucket": "release",
111+
"EnableFeature": [ "ArtifactAsFolder" ]
100112
}
101113
]
102114
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM mcr.microsoft.com/powershell:6.1.0-alpine-3.8
2+
3+
RUN apk update \
4+
&& apk add build-base gcc abuild binutils git python bash cmake
5+
6+
ENTRYPOINT [ "pwsh" ]

0 commit comments

Comments
 (0)