2
0
Эх сурвалжийг харах

fix(alpine): download node's docker image (#2013)

Baptiste Augrain 11 сар өмнө
parent
commit
5cb1be9c61

+ 12 - 0
package_alpine_reh.sh

@@ -19,6 +19,18 @@ VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME="vscodium/vscodium-linux-build-agent:a
 
 export VSCODE_HOST_MOUNT VSCODE_REMOTE_DEPENDENCIES_CONTAINER_NAME
 
+if [[ -d "../patches/alpine/reh/" ]]; then
+  for file in "../patches/alpine/reh/"*.patch; do
+    if [[ -f "${file}" ]]; then
+      echo applying patch: "${file}";
+      if ! git apply --ignore-whitespace "${file}"; then
+        echo failed to apply patch "${file}" >&2
+        exit 1
+      fi
+    fi
+  done
+fi
+
 for i in {1..5}; do # try 5 times
   yarn --frozen-lockfile --check-files && break
   if [[ $i == 3 ]]; then

+ 23 - 0
patches/alpine/reh/fix-node-docker.patch

@@ -0,0 +1,23 @@
+diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js
+index e12a33e..9300d62 100644
+--- a/build/gulpfile.reh.js
++++ b/build/gulpfile.reh.js
+@@ -188,5 +188,16 @@ function getNodeChecksum(expectedName) {
+ function extractAlpinefromDocker(nodeVersion, platform, arch) {
+-	const imageName = arch === 'arm64' ? 'arm64v8/node' : 'node';
++	let imageName = 'node';
++	let dockerPlatform = '';
++
++	if (arch === 'arm64') {
++		imageName = 'arm64v8/node';
++
++		const architecture = cp.execSync(`docker info --format '{{json .Architecture}}'`, { encoding: 'utf8' }).trim();
++		if (architecture != '"aarch64"') {
++			dockerPlatform = '--platform=linux/arm64';
++		}
++	}
++
+ 	log(`Downloading node.js ${nodeVersion} ${platform} ${arch} from docker image ${imageName}`);
+-	const contents = cp.execSync(`docker run --rm ${imageName}:${nodeVersion}-alpine /bin/sh -c 'cat \`which node\`'`, { maxBuffer: 100 * 1024 * 1024, encoding: 'buffer' });
++	const contents = cp.execSync(`docker run --rm ${dockerPlatform} ${imageName}:${nodeVersion}-alpine /bin/sh -c 'cat \`which node\`'`, { maxBuffer: 100 * 1024 * 1024, encoding: 'buffer' });
+ 	return es.readArray([new File({ path: 'node', contents, stat: { mode: parseInt('755', 8) } })]);