@@ -138,13 +138,10 @@ function getNodeChecksum(nodeVersion, platform, arch) {
138
138
break ;
139
139
140
140
case 'darwin' :
141
+ case 'alpine' :
141
142
case 'linux' :
142
143
expectedName = `node-v${ nodeVersion } -${ platform } -${ arch } .tar.gz` ;
143
144
break ;
144
-
145
- case 'alpine' :
146
- expectedName = `${ platform } -${ arch } /node` ;
147
- break ;
148
145
}
149
146
150
147
const nodeJsChecksums = fs . readFileSync ( path . join ( REPO_ROOT , 'build' , 'checksums' , 'nodejs.txt' ) , 'utf8' ) ;
@@ -157,6 +154,13 @@ function getNodeChecksum(nodeVersion, platform, arch) {
157
154
return undefined ;
158
155
}
159
156
157
+ function extractAlpinefromDocker ( nodeVersion , platform , arch ) {
158
+ const imageName = arch === 'arm64' ? 'arm64v8/node' : 'node' ;
159
+ log ( `Downloading node.js ${ nodeVersion } ${ platform } ${ arch } from docker image ${ imageName } ` ) ;
160
+ const contents = cp . execSync ( `docker run --rm ${ imageName } :${ nodeVersion } -alpine /bin/sh -c 'cat \`which node\`'` , { maxBuffer : 100 * 1024 * 1024 , encoding : 'buffer' } ) ;
161
+ return es . readArray ( [ new File ( { path : 'node' , contents, stat : { mode : parseInt ( '755' , 8 ) } } ) ] ) ;
162
+ }
163
+
160
164
const { nodeVersion, internalNodeVersion } = getNodeVersion ( ) ;
161
165
162
166
BUILD_TARGETS . forEach ( ( { platform, arch } ) => {
@@ -219,18 +223,14 @@ function nodejs(platform, arch) {
219
223
. pipe ( filter ( '**/node' ) )
220
224
. pipe ( util . setExecutableBit ( '**' ) )
221
225
. pipe ( rename ( 'node' ) ) ;
222
- case 'alpine' : {
223
- const imageName = arch === 'arm64' ? 'arm64v8/node' : 'node' ;
224
- log ( `Downloading node.js ${ nodeVersion } ${ platform } ${ arch } from docker image ${ imageName } ` ) ;
225
- const contents = cp . execSync ( `docker run --rm ${ imageName } :${ nodeVersion } -alpine /bin/sh -c 'cat \`which node\`'` , { maxBuffer : 100 * 1024 * 1024 , encoding : 'buffer' } ) ;
226
- if ( checksumSha256 ) {
227
- const actualSHA256Checksum = crypto . createHash ( 'sha256' ) . update ( contents ) . digest ( 'hex' ) ;
228
- if ( actualSHA256Checksum !== checksumSha256 ) {
229
- throw new Error ( `Checksum mismatch for node.js from docker image (expected ${ options . checksumSha256 } , actual ${ actualSHA256Checksum } ))` ) ;
230
- }
231
- }
232
- return es . readArray ( [ new File ( { path : 'node' , contents, stat : { mode : parseInt ( '755' , 8 ) } } ) ] ) ;
233
- }
226
+ case 'alpine' :
227
+ return product . nodejsRepository !== 'https://nodejs.org' ?
228
+ fetchGithub ( product . nodejsRepository , { version : `${ nodeVersion } -${ internalNodeVersion } ` , name : `node-v${ nodeVersion } -${ platform } -${ arch } .tar.gz` , checksumSha256 } )
229
+ . pipe ( flatmap ( stream => stream . pipe ( gunzip ( ) ) . pipe ( untar ( ) ) ) )
230
+ . pipe ( filter ( '**/node' ) )
231
+ . pipe ( util . setExecutableBit ( '**' ) )
232
+ . pipe ( rename ( 'node' ) )
233
+ : extractAlpinefromDocker ( nodeVersion , platform , arch ) ;
234
234
}
235
235
}
236
236
0 commit comments