|
| 1 | +parameters: |
| 2 | + - name: ARCHITECTURE |
| 3 | + type: string |
| 4 | + default: 'x64' |
| 5 | + - name: Name |
| 6 | + type: string |
| 7 | + default: 'Build_musl_x64' |
| 8 | + - name: hostArchitecture |
| 9 | + type: string |
| 10 | + default: 'amd64' |
| 11 | + |
| 12 | +jobs: |
| 13 | +- job: PrepareDockerBuild |
| 14 | + pool: |
| 15 | + type: linux |
| 16 | + ${{ if eq(parameters.hostArchitecture, 'arm64') }}: |
| 17 | + hostArchitecture: 'arm64' |
| 18 | + displayName: Prepare_Docker_Build |
| 19 | + variables: |
| 20 | + - name: ob_outputDirectory |
| 21 | + value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT' |
| 22 | + - name: ob_signing_setup_enabled |
| 23 | + value: true |
| 24 | + - name: LinuxContainerImage |
| 25 | + value: mcr.microsoft.com/onebranch/azurelinux/build:3.0 |
| 26 | + steps: |
| 27 | + - checkout: self |
| 28 | + clean: true |
| 29 | + |
| 30 | + - pwsh: | |
| 31 | + Get-ChildItem Env:\ | Out-String -Stream | Write-Verbose -Verbose |
| 32 | + displayName: Capture environment variables |
| 33 | +
|
| 34 | + - pwsh: | |
| 35 | + New-Item -ItemType Directory -Path "$(ob_outputDirectory)" | Out-Null |
| 36 | + displayName: 'Create output directory' |
| 37 | +
|
| 38 | + - pwsh: | |
| 39 | + Copy-Item -Path "$(Build.SourcesDirectory)/*" -Destination "$(ob_outputDirectory)" -Force -Verbose -Recurse |
| 40 | + displayName: 'Copy Dockerfile to output directory' |
| 41 | +
|
| 42 | +- job: ${{ parameters.Name }} |
| 43 | + pool: |
| 44 | + type: docker |
| 45 | + os: linux |
| 46 | + ${{ if eq(parameters.hostArchitecture, 'arm64') }}: |
| 47 | + hostArchitecture: 'arm64' |
| 48 | + displayName: Linux_MUSL_${{ parameters.ARCHITECTURE }} |
| 49 | + dependsOn: PrepareDockerBuild |
| 50 | + variables: |
| 51 | + - name: LinuxContainerImage |
| 52 | + value: mcr.microsoft.com/dotnet/sdk:10.0-alpine |
| 53 | + - name: ob_outputDirectory |
| 54 | + value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT' |
| 55 | + - name: ob_signing_setup_enabled |
| 56 | + value: true |
| 57 | + - name: ARCHITECTURE |
| 58 | + value: ${{ parameters.ARCHITECTURE }} |
| 59 | + - name: DOTNET_SYSTEM_GLOBALIZATION_INVARIANT |
| 60 | + value: 1 |
| 61 | + - ${{ if eq(parameters.ARCHITECTURE, 'linux-musl-arm64') }}: |
| 62 | + - name: ob_sdl_binskim_enabled |
| 63 | + value: false |
| 64 | + - name: ob_sdl_credscan_enabled |
| 65 | + value: false |
| 66 | + steps: |
| 67 | + - task: DownloadPipelineArtifact@2 |
| 68 | + displayName: 'Download prepared Docker build context' |
| 69 | + inputs: |
| 70 | + buildType: 'current' |
| 71 | + artifactName: 'drop_LinuxMuslBuild_PrepareDockerBuild' |
| 72 | + targetPath: '$(Build.SourcesDirectory)/dst/drop_LinuxMuslBuild_PrepareDockerBuild' |
| 73 | + |
| 74 | + - task: onebranch.pipeline.imagebuildinfo@1 |
| 75 | + displayName: 'Build Alpine Image' |
| 76 | + inputs: |
| 77 | + repositoryName: 'psnative-alpine' |
| 78 | + dockerFileRelPath: 'drop_LinuxMuslBuild_PrepareDockerBuild/powershell-native/Dockerfile' |
| 79 | + dockerFileContextPath: 'drop_LinuxMuslBuild_PrepareDockerBuild/powershell-native' |
| 80 | + addPipelineData: false |
| 81 | + saveImageToPath: docker-images/psnative-alpine.tar |
| 82 | + build_tag: $(Build.BuildId) |
| 83 | + compress: false |
| 84 | + enable_isolated_acr_push: false |
| 85 | + enable_service_tree_acr_path: false |
| 86 | + enable_network: true |
| 87 | + |
| 88 | +- job: ExtractLibPSL |
| 89 | + displayName: 'Extract libpsl-native.so' |
| 90 | + dependsOn: ${{ parameters.Name }} |
| 91 | + pool: |
| 92 | + type: linux |
| 93 | + variables: |
| 94 | + - name: LinuxContainerImage |
| 95 | + value: mcr.microsoft.com/onebranch/azurelinux/build:3.0 |
| 96 | + - name: ob_outputDirectory |
| 97 | + value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT' |
| 98 | + - name: ob_signing_setup_enabled |
| 99 | + value: false |
| 100 | + |
| 101 | + steps: |
| 102 | + - checkout: self |
| 103 | + clean: true |
| 104 | + |
| 105 | + - download: current |
| 106 | + artifact: drop_LinuxMuslBuild_Build_Linux_musl_x64 |
| 107 | + patterns: docker-images/psnative-alpine.tar |
| 108 | + displayName: 'Download Docker image artifact' |
| 109 | + |
| 110 | + - pwsh: | |
| 111 | + Get-ChildItem $(Pipeline.Workspace)/drop_LinuxMuslBuild_Build_Linux_musl_x64 -Recurse | Out-String -Stream | Write-Verbose -Verbose |
| 112 | + displayName: Capture downloaded artifacts |
| 113 | +
|
| 114 | + - pwsh: | |
| 115 | + New-Item -ItemType Directory -Path "$(ob_outputDirectory)" | Out-Null |
| 116 | + New-Item -ItemType Directory -Path $(Pipeline.Workspace)/temp | Out-Null |
| 117 | + tar -xvf $(Pipeline.Workspace)/drop_LinuxMuslBuild_Build_Linux_musl_x64/docker-images/psnative-alpine.tar -C $(Pipeline.Workspace)/temp |
| 118 | + $manifest = Get-Content "$(Pipeline.Workspace)/temp/manifest.json" |
| 119 | + $manifest | Out-String -Stream | Write-Verbose -Verbose |
| 120 | +
|
| 121 | + $manifestJson = $manifest | ConvertFrom-Json |
| 122 | + $imageId = $manifestJson[0].Layers[0] |
| 123 | + $libPSLPath = "$(Pipeline.Workspace)/temp/$imageId" |
| 124 | +
|
| 125 | + Write-Verbose "Extracted layer path: $libPSLPath" -Verbose |
| 126 | + Get-ChildItem -Path "$libPSLPath" -Recurse | Out-String -Stream | Write-Verbose -Verbose |
| 127 | +
|
| 128 | + tar -xvf $libPSLPath |
| 129 | +
|
| 130 | + Get-ChildItem -Path . | Out-String -Stream | Write-Verbose -Verbose |
| 131 | +
|
| 132 | + Copy-Item -Path ./libpsl-native.so -Destination "$(ob_outputDirectory)/libpsl-native.so" -Force -Verbose |
| 133 | + displayName: 'Extract libpsl-native.so from image' |
0 commit comments