Skip to content

Commit 650d00c

Browse files
dmitrivMSCopilot
andauthored
build: adopt cached QEMU and refresh Alpine images (#346617)
* build: adopt cached QEMU and refresh Alpine images Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * build: always pull current Alpine build images Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 973dcf3 commit 650d00c

4 files changed

Lines changed: 42 additions & 25 deletions

File tree

‎build/azure-pipelines/alpine/product-build-alpine-node-modules.yml‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- template: ../common/apply-sdk-canary.yml@self
3636

37-
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
37+
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) alpine-3.22 > .build/packagelockhash
3838
displayName: Prepare node_modules cache key
3939

4040
- task: Cache@2
@@ -69,26 +69,21 @@ jobs:
6969
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
7070
displayName: Setup NuGet Authentication
7171

72+
- template: ../common/setup-qemu.yml@self
73+
parameters:
74+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['NPM_ARCH'], 'arm64'))
75+
7276
- task: Docker@1
7377
inputs:
7478
azureSubscriptionEndpoint: vscode
7579
azureContainerRegistry: vscodehub.azurecr.io
7680
command: "Run an image"
7781
imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"
82+
arguments: --pull=always
7883
containerCommand: uname
7984
displayName: "Pull image"
8085
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
8186

82-
- task: Docker@1
83-
inputs:
84-
azureSubscriptionEndpoint: vscode
85-
azureContainerRegistry: vscodehub.azurecr.io
86-
command: "Run an image"
87-
imageName: "multiarch/qemu-user-static@sha256:fe60359c92e86a43cc87b3d906006245f77bfc0565676b80004cc666e4feb9f0"
88-
containerCommand: uname
89-
displayName: "Pull qemu-user-static image"
90-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['NPM_ARCH'], 'arm64'))
91-
9287
- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev
9388
displayName: Install build dependencies
9489
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))

‎build/azure-pipelines/alpine/product-build-alpine.yml‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
8383
displayName: Setup NPM Registry
8484

85-
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
85+
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.ts alpine $VSCODE_ARCH $(node -p process.arch) alpine-3.22 > .build/packagelockhash
8686
displayName: Prepare node_modules cache key
8787

8888
- task: Cache@2
@@ -118,26 +118,21 @@ jobs:
118118
- task: NuGetAuthenticate@1
119119
displayName: Setup NuGet Authentication
120120

121+
- template: ../common/setup-qemu.yml@self
122+
parameters:
123+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['NPM_ARCH'], 'arm64'))
124+
121125
- task: Docker@1
122126
inputs:
123127
azureSubscriptionEndpoint: vscode
124128
azureContainerRegistry: vscodehub.azurecr.io
125129
command: "Run an image"
126130
imageName: "vscode-linux-build-agent:alpine-$(VSCODE_ARCH)"
131+
arguments: --pull=always
127132
containerCommand: uname
128133
displayName: "Pull image"
129134
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
130135

131-
- task: Docker@1
132-
inputs:
133-
azureSubscriptionEndpoint: vscode
134-
azureContainerRegistry: vscodehub.azurecr.io
135-
command: "Run an image"
136-
imageName: "multiarch/qemu-user-static@sha256:fe60359c92e86a43cc87b3d906006245f77bfc0565676b80004cc666e4feb9f0"
137-
containerCommand: uname
138-
displayName: "Pull qemu-user-static image"
139-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['NPM_ARCH'], 'arm64'))
140-
141136
- script: sudo apt-get update && sudo apt-get install -y libkrb5-dev
142137
displayName: Install build dependencies
143138
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
parameters:
5+
- name: condition
6+
type: string
7+
default: succeeded()
8+
9+
steps:
10+
- task: Docker@1
11+
inputs:
12+
azureSubscriptionEndpoint: vscode
13+
azureContainerRegistry: vscodehub.azurecr.io
14+
command: "Run an image"
15+
imageName: "cache/docker/tonistiigi/binfmt:qemu-v10.2.3-68@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0"
16+
containerCommand: --version
17+
displayName: Pull QEMU image
18+
condition: ${{ parameters.condition }}
19+
20+
# Register once before dependency installs, which may run concurrently.
21+
- script: |
22+
set -euo pipefail
23+
jq --version
24+
BINFMT_IMAGE=vscodehub.azurecr.io/cache/docker/tonistiigi/binfmt:qemu-v10.2.3-68@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
25+
sudo docker run --rm --privileged --pull=never --platform linux/amd64 "$BINFMT_IMAGE" --uninstall 'qemu-*' |
26+
jq -e 'if any(.emulators[]?; startswith("qemu-")) then error("Failed to remove existing QEMU handlers") else . end'
27+
sudo docker run --rm --privileged --pull=never --platform linux/amd64 "$BINFMT_IMAGE" --install arm64,arm |
28+
jq -e 'if (.supported | index("linux/arm64") != null and index("linux/arm/v7") != null) then . else error("ARM64/ARM emulation is unavailable") end'
29+
displayName: Register Docker QEMU
30+
condition: ${{ parameters.condition }}

‎build/npm/postinstall.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ async function pnpmInstallAsync(dir: string, env: NodeJS.ProcessEnv): Promise<vo
8282
const storeDir = '/root/vscode/.build/pnpm-store-container';
8383
log(dir, `Installing dependencies inside container ${process.env['VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME']}...`);
8484

85-
if (process.env['npm_config_arch'] === 'arm64') {
86-
run('sudo', ['docker', 'run', '--rm', '--privileged', 'vscodehub.azurecr.io/multiarch/qemu-user-static@sha256:fe60359c92e86a43cc87b3d906006245f77bfc0565676b80004cc666e4feb9f0', '--reset', '-p', 'yes'], syncOpts);
87-
}
8885
run('sudo', [
8986
'docker', 'run',
9087
'-e', 'GITHUB_TOKEN',

0 commit comments

Comments
 (0)