@@ -138,13 +138,10 @@ function getNodeChecksum(nodeVersion, platform, arch) {
138138 break ;
139139
140140 case 'darwin' :
141+ case 'alpine' :
141142 case 'linux' :
142143 expectedName = `node-v${ nodeVersion } -${ platform } -${ arch } .tar.gz` ;
143144 break ;
144-
145- case 'alpine' :
146- expectedName = `${ platform } -${ arch } /node` ;
147- break ;
148145 }
149146
150147 const nodeJsChecksums = fs . readFileSync ( path . join ( REPO_ROOT , 'build' , 'checksums' , 'nodejs.txt' ) , 'utf8' ) ;
@@ -157,6 +154,13 @@ function getNodeChecksum(nodeVersion, platform, arch) {
157154 return undefined ;
158155}
159156
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+
160164const { nodeVersion, internalNodeVersion } = getNodeVersion ( ) ;
161165
162166BUILD_TARGETS . forEach ( ( { platform, arch } ) => {
@@ -219,18 +223,14 @@ function nodejs(platform, arch) {
219223 . pipe ( filter ( '**/node' ) )
220224 . pipe ( util . setExecutableBit ( '**' ) )
221225 . 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 ) ;
234234 }
235235}
236236
0 commit comments