@@ -30,7 +30,7 @@ async function push(repo, release, updateLatest, registry, registryPath, stubReg
30
30
const stagingFolder = await configUtils . getStagingFolder ( release ) ;
31
31
await configUtils . loadConfig ( stagingFolder ) ;
32
32
33
- // Use or create a buildx / buildkit "builder" that using the docker-container driver that
33
+ // Use or create a buildx / buildkit "builder" that using the docker-container driver which internally
34
34
// uses QEMU to emulate different architectures for cross-platform builds. Setting up a separate
35
35
// builder avoids problems with the default config being different otherwise altered. It also can
36
36
// be tweaked down the road to use a different driver like using separate machines per architecture.
@@ -99,7 +99,8 @@ async function pushImage(definitionId, repo, release, updateLatest,
99
99
// Determine tags to use
100
100
const versionTags = configUtils . getTagList ( definitionId , release , updateLatest , registry , registryPath , variant ) ;
101
101
console . log ( `(*) Tags:${ versionTags . reduce ( ( prev , current ) => prev += `\n ${ current } ` , '' ) } ` ) ;
102
- let architectures = configUtils . getBuildSettings ( definitionId ) . architectures ;
102
+ const buildSettings = configUtils . getBuildSettings ( definitionId ) ;
103
+ let architectures = buildSettings . architectures ;
103
104
switch ( typeof architectures ) {
104
105
case 'string' : architectures = [ architectures ] ; break ;
105
106
case 'object' : if ( ! Array . isArray ( architectures ) ) { architectures = architectures [ variant ] ; } break ;
@@ -122,9 +123,23 @@ async function pushImage(definitionId, repo, release, updateLatest,
122
123
if ( replaceImage || ! await isDefinitionVersionAlreadyPublished ( definitionId , release , registry , registryPath , variant ) ) {
123
124
const context = devContainerJson . build ? devContainerJson . build . context || '.' : devContainerJson . context || '.' ;
124
125
const workingDir = path . resolve ( dotDevContainerPath , context ) ;
126
+ // Add tags to buildx command params
127
+ const buildParams = versionTags . reduce ( ( prev , current ) => prev . concat ( [ '-t' , current ] ) , [ ] ) ;
125
128
// Note: build.args in devcontainer.json is intentionally ignored so you can vary image contents and defaults as needed
126
- const buildParams = ( variant ? [ '--build-arg' , `VARIANT=${ variant } ` ] : [ ] )
127
- . concat ( versionTags . reduce ( ( prev , current ) => prev . concat ( [ '-t' , current ] ) , [ ] ) ) ;
129
+ // Add VARIANT --build-arg if applicable
130
+ if ( variant ) {
131
+ buildParams . push ( '--build-arg' , `VARIANT=${ variant } ` ) ;
132
+ }
133
+ // Generate list of --build-arg values if applicable
134
+ for ( let buildArg in buildSettings . buildArgs || { } ) {
135
+ buildParams . push ( '--build-arg' , `${ buildArg } =${ buildSettings . buildArgs [ buildArg ] } ` ) ;
136
+ }
137
+ // Generate list of variant specific --build-arg values if applicable
138
+ if ( buildSettings . variantBuildArgs ) {
139
+ for ( let buildArg in buildSettings . variantBuildArgs [ variant ] || { } ) {
140
+ buildParams . push ( '--build-arg' , `${ buildArg } =${ buildSettings . variantBuildArgs [ variant ] [ buildArg ] } ` ) ;
141
+ }
142
+ }
128
143
const spawnOpts = { stdio : 'inherit' , cwd : workingDir , shell : true } ;
129
144
await asyncUtils . spawn ( 'docker' , [
130
145
'buildx' ,
0 commit comments