Path: blob/main/build/azure-pipelines/alpine/product-build-alpine.yml
3520 views
steps:1- template: ../common/checkout.yml@self23- task: NodeTool@04inputs:5versionSource: fromFile6versionFilePath: .nvmrc78- template: ../distro/download-distro.yml@self910- task: AzureKeyVault@211displayName: "Azure Key Vault: Get Secrets"12inputs:13azureSubscription: vscode14KeyVaultName: vscode-build-secrets15SecretsFilter: "github-distro-mixin-password"1617- task: DownloadPipelineArtifact@218inputs:19artifact: Compilation20path: $(Build.ArtifactStagingDirectory)21displayName: Download compilation output2223- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz24displayName: Extract compilation output2526- script: node build/setup-npm-registry.js $NPM_REGISTRY27condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))28displayName: Setup NPM Registry2930- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash31displayName: Prepare node_modules cache key3233- task: Cache@234inputs:35key: '"node_modules" | .build/packagelockhash'36path: .build/node_modules_cache37cacheHitVar: NODE_MODULES_RESTORED38displayName: Restore node_modules cache3940- script: tar -xzf .build/node_modules_cache/cache.tgz41condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))42displayName: Extract node_modules cache4344- script: |45set -e46# Set the private NPM registry to the global npmrc file47# so that authentication works for subfolders like build/, remote/, extensions/ etc48# which does not have their own .npmrc file49npm config set registry "$NPM_REGISTRY"50echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"51condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))52displayName: Setup NPM5354- task: npmAuthenticate@055inputs:56workingFile: $(NPMRC_PATH)57condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))58displayName: Setup NPM Authentication5960- task: Docker@161inputs:62azureSubscriptionEndpoint: vscode63azureContainerRegistry: vscodehub.azurecr.io64command: "Run an image"65imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"66containerCommand: uname67displayName: "Pull image"68condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))6970- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev71displayName: Install build dependencies72condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))7374- script: |75set -e76mkdir -p .build/nodejs-musl77NODE_VERSION=$(grep '^target=' remote/.npmrc | cut -d '"' -f 2)78BUILD_ID=$(grep '^ms_build_id=' remote/.npmrc | cut -d '"' -f 2)79gh 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 --clobber80tar -xzf ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz" -C ".build/nodejs-musl" --strip-components=181rm ".build/nodejs-musl/node-v${NODE_VERSION}-linux-${VSCODE_ARCH}-musl.tar.gz"82env:83GITHUB_TOKEN: "$(github-distro-mixin-password)"84displayName: Download NodeJS MUSL85condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))8687- script: |88set -e8990for i in {1..5}; do # try 5 times91npm ci && break92if [ $i -eq 5 ]; then93echo "Npm install failed too many times" >&294exit 195fi96echo "Npm install failed $i, trying again..."97done98env:99npm_config_arch: $(NPM_ARCH)100ELECTRON_SKIP_BINARY_DOWNLOAD: 1101PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1102GITHUB_TOKEN: "$(github-distro-mixin-password)"103VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME: vscodehub.azurecr.io/vscode-linux-build-agent:alpine-$(VSCODE_ARCH)104VSCODE_HOST_MOUNT: "/mnt/vss/_work/1/s"105VSCODE_NPMRC_PATH: $(NPMRC_PATH)106displayName: Install dependencies107condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))108109- script: node build/azure-pipelines/distro/mixin-npm110displayName: Mixin distro node modules111condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))112113- script: |114set -e115node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt116mkdir -p .build/node_modules_cache117tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt118condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))119displayName: Create node_modules archive120121- script: node build/azure-pipelines/distro/mixin-quality122displayName: Mixin distro quality123124- template: ../common/install-builtin-extensions.yml@self125126- script: |127set -e128TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64") # TODO@joaomoreno129npm run gulp vscode-reh-$TARGET-min-ci130(cd .. && mv vscode-reh-$TARGET vscode-server-$TARGET) # TODO@joaomoreno131ARCHIVE_PATH=".build/linux/server/vscode-server-$TARGET.tar.gz"132DIR_PATH="$(realpath ../vscode-server-$TARGET)"133mkdir -p $(dirname $ARCHIVE_PATH)134tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET135echo "##vso[task.setvariable variable=SERVER_DIR_PATH]$DIR_PATH"136echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"137env:138GITHUB_TOKEN: "$(github-distro-mixin-password)"139displayName: Build server140141- script: |142set -e143TARGET=$([ "$VSCODE_ARCH" == "x64" ] && echo "linux-alpine" || echo "alpine-arm64")144npm run gulp vscode-reh-web-$TARGET-min-ci145(cd .. && mv vscode-reh-web-$TARGET vscode-server-$TARGET-web) # TODO@joaomoreno146ARCHIVE_PATH=".build/linux/web/vscode-server-$TARGET-web.tar.gz"147DIR_PATH="$(realpath ../vscode-server-$TARGET-web)"148mkdir -p $(dirname $ARCHIVE_PATH)149tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-$TARGET-web150echo "##vso[task.setvariable variable=WEB_DIR_PATH]$DIR_PATH"151echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"152env:153GITHUB_TOKEN: "$(github-distro-mixin-password)"154displayName: Build server (web)155156- script: echo "##vso[task.setvariable variable=ARTIFACT_PREFIX]attempt$(System.JobAttempt)_"157condition: and(succeededOrFailed(), notIn(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues'))158displayName: Generate artifact prefix159160- template: ../common/publish-artifact.yml@self161parameters:162targetPath: $(SERVER_PATH)163artifactName: $(ARTIFACT_PREFIX)vscode_server_alpine_$(VSCODE_ARCH)_archive-unsigned164displayName: Publish server archive165sbomBuildDropPath: $(SERVER_DIR_PATH)166sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Server"167sbomPackageVersion: $(Build.SourceVersion)168condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''), ne(variables['VSCODE_ARCH'], 'x64'))169170- template: ../common/publish-artifact.yml@self171parameters:172targetPath: $(WEB_PATH)173artifactName: $(ARTIFACT_PREFIX)vscode_web_alpine_$(VSCODE_ARCH)_archive-unsigned174displayName: Publish web server archive175sbomBuildDropPath: $(WEB_DIR_PATH)176sbomPackageName: "VS Code Alpine $(VSCODE_ARCH) Web"177sbomPackageVersion: $(Build.SourceVersion)178condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''), ne(variables['VSCODE_ARCH'], 'x64'))179180# same as above, keep legacy name181- template: ../common/publish-artifact.yml@self182parameters:183targetPath: $(SERVER_PATH)184artifactName: $(ARTIFACT_PREFIX)vscode_server_linux_alpine_archive-unsigned185displayName: Publish x64 server archive186sbomEnabled: false187condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''), eq(variables['VSCODE_ARCH'], 'x64'))188189# same as above, keep legacy name190- template: ../common/publish-artifact.yml@self191parameters:192targetPath: $(WEB_PATH)193artifactName: $(ARTIFACT_PREFIX)vscode_web_linux_alpine_archive-unsigned194displayName: Publish x64 web server archive195sbomEnabled: false196condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''), eq(variables['VSCODE_ARCH'], 'x64'))197198199