Path: blob/main/build/azure-pipelines/alpine/product-build-alpine.yml
5379 views
parameters:1- name: VSCODE_ARCH2type: string34jobs:5- job: Alpine_${{ parameters.VSCODE_ARCH }}6displayName: Alpine (${{ upper(parameters.VSCODE_ARCH) }})7timeoutInMinutes: 308pool:9name: 1es-ubuntu-22.04-x6410os: linux11variables:12NPM_ARCH: ${{ parameters.VSCODE_ARCH }}13VSCODE_ARCH: ${{ parameters.VSCODE_ARCH }}14templateContext:15outputParentDirectory: $(Build.ArtifactStagingDirectory)/out16outputs:17- ${{ if eq(parameters.VSCODE_ARCH, 'x64') }}:18# keep legacy name19- output: pipelineArtifact20targetPath: $(Build.ArtifactStagingDirectory)/out/server/vscode-server-linux-alpine.tar.gz21artifactName: vscode_server_linux_alpine_archive-unsigned22displayName: Publish x64 server archive23sbomBuildDropPath: $(SERVER_DIR_PATH)24sbomPackageName: "VS Code Alpine x64 Server"25sbomPackageVersion: $(Build.SourceVersion)26# keep legacy name27- output: pipelineArtifact28targetPath: $(Build.ArtifactStagingDirectory)/out/web/vscode-server-linux-alpine-web.tar.gz29artifactName: vscode_web_linux_alpine_archive-unsigned30displayName: Publish x64 web server archive31sbomBuildDropPath: $(WEB_DIR_PATH)32sbomPackageName: "VS Code Alpine x64 Web"33sbomPackageVersion: $(Build.SourceVersion)34- ${{ if ne(parameters.VSCODE_ARCH, 'x64') }}:35- output: pipelineArtifact36targetPath: $(Build.ArtifactStagingDirectory)/out/server/vscode-server-alpine-$(VSCODE_ARCH).tar.gz37artifactName: vscode_server_alpine_$(VSCODE_ARCH)_archive-unsigned38displayName: Publish server archive39sbomBuildDropPath: $(SERVER_DIR_PATH)40sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Server"41sbomPackageVersion: $(Build.SourceVersion)42- output: pipelineArtifact43targetPath: $(Build.ArtifactStagingDirectory)/out/web/vscode-server-alpine-$(VSCODE_ARCH)-web.tar.gz44artifactName: vscode_web_alpine_$(VSCODE_ARCH)_archive-unsigned45displayName: Publish web server archive46sbomBuildDropPath: $(WEB_DIR_PATH)47sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Web"48sbomPackageVersion: $(Build.SourceVersion)49steps:50- template: ../common/checkout.yml@self5152- task: NodeTool@053inputs:54versionSource: fromFile55versionFilePath: .nvmrc5657- template: ../distro/download-distro.yml@self5859- task: AzureKeyVault@260displayName: "Azure Key Vault: Get Secrets"61inputs:62azureSubscription: vscode63KeyVaultName: vscode-build-secrets64SecretsFilter: "github-distro-mixin-password"6566- task: DownloadPipelineArtifact@267inputs:68artifact: Compilation69path: $(Build.ArtifactStagingDirectory)70displayName: Download compilation output7172- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz73displayName: Extract compilation output7475- script: node build/setup-npm-registry.ts $NPM_REGISTRY76condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))77displayName: Setup NPM Registry7879- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash80displayName: Prepare node_modules cache key8182- task: Cache@283inputs:84key: '"node_modules" | .build/packagelockhash'85path: .build/node_modules_cache86cacheHitVar: NODE_MODULES_RESTORED87displayName: Restore node_modules cache8889- script: tar -xzf .build/node_modules_cache/cache.tgz90condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))91displayName: Extract node_modules cache9293- script: |94set -e95# Set the private NPM registry to the global npmrc file96# so that authentication works for subfolders like build/, remote/, extensions/ etc97# which does not have their own .npmrc file98npm config set registry "$NPM_REGISTRY"99echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"100condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))101displayName: Setup NPM102103- task: npmAuthenticate@0104inputs:105workingFile: $(NPMRC_PATH)106condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))107displayName: Setup NPM Authentication108109- task: Docker@1110inputs:111azureSubscriptionEndpoint: vscode112azureContainerRegistry: vscodehub.azurecr.io113command: "Run an image"114imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"115containerCommand: uname116displayName: "Pull image"117condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))118119- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev120displayName: Install build dependencies121condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))122123- script: |124set -e125mkdir -p .build/nodejs-musl126NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)127BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)128gh release download "v${NODE_VERSION}-${BUILD_ID}" -R microsoft/vscode-node -p "node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" --dir .build/nodejs-musl --clobber129tar -xzf ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" -C ".build/nodejs-musl" --strip-components=1130rm ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz"131env:132GITHUB_TOKEN: "$(github-distro-mixin-password)"133displayName: Download NodeJS MUSL134condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))135136- script: |137set -e138139for i in {1..5}; do # try 5 times140npm ci && break141if [ $i -eq 5 ]; then142echo "Npm install failed too many times" >&2143exit 1144fi145echo "Npm install failed $i, trying again..."146done147env:148npm_config_arch: $(NPM_ARCH)149ELECTRON_SKIP_BINARY_DOWNLOAD: 1150PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1151GITHUB_TOKEN: "$(github-distro-mixin-password)"152VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME: vscodehub.azurecr.io/vscode-linux-build-agent:alpine-$(VSCODE_ARCH)153VSCODE_HOST_MOUNT: "/mnt/vss/_work/1/s"154VSCODE_NPMRC_PATH: $(NPMRC_PATH)155displayName: Install dependencies156condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))157158- script: node build/azure-pipelines/distro/mixin-npm.ts159displayName: Mixin distro node modules160condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))161162- script: |163set -e164node build/azure-pipelines/common/listNodeModules.ts .build/node_modules_list.txt165mkdir -p .build/node_modules_cache166tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt167condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))168displayName: Create node_modules archive169170- script: node build/azure-pipelines/distro/mixin-quality.ts171displayName: Mixin distro quality172173- template: ../common/install-builtin-extensions.yml@self174175- script: |176set -e177TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64") # TODO@joaomoreno178npm run gulp vscode-reh-$TARGET-min-ci179(cd .. && mv vscode-reh-$TARGET vscode-server-$TARGET) # TODO@joaomoreno180ARCHIVE_PATH="$(Build.ArtifactStagingDirectory)/out/server/vscode-server-$TARGET.tar.gz"181DIR_PATH="$(realpath ../vscode-server-$TARGET)"182mkdir -p $(dirname $ARCHIVE_PATH)183tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET184echo "##vso[task.setvariable variable=SERVER_DIR_PATH]$DIR_PATH"185echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"186env:187GITHUB_TOKEN: "$(github-distro-mixin-password)"188displayName: Build server189190- script: |191set -e192TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64")193npm run gulp vscode-reh-web-$TARGET-min-ci194(cd .. && mv vscode-reh-web-$TARGET vscode-server-$TARGET-web) # TODO@joaomoreno195ARCHIVE_PATH="$(Build.ArtifactStagingDirectory)/out/web/vscode-server-$TARGET-web.tar.gz"196DIR_PATH="$(realpath ../vscode-server-$TARGET-web)"197mkdir -p $(dirname $ARCHIVE_PATH)198tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET-web199echo "##vso[task.setvariable variable=WEB_DIR_PATH]$DIR_PATH"200echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"201env:202GITHUB_TOKEN: "$(github-distro-mixin-password)"203displayName: Build server (web)204205206