@leverege/build-tools 2.68.2 → 2.68.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/Docker.mjs
CHANGED
|
@@ -47,7 +47,8 @@ const bashrcPluginTemplate = `
|
|
|
47
47
|
#
|
|
48
48
|
`
|
|
49
49
|
const bashrcTemplate = fs.readFileSync( path.join( DIRNAME, './templates/bashrcTemplate.hbs' ), 'utf8' )
|
|
50
|
-
const
|
|
50
|
+
const cloudBuildStepsSingleArch = fs.readFileSync( path.join( DIRNAME, './templates/cloudBuildSingleArch.hbs' ), 'utf8' )
|
|
51
|
+
const cloudBuildStepsMultiArch = fs.readFileSync( path.join( DIRNAME, './templates/cloudBuildMultiArch.hbs' ), 'utf8' )
|
|
51
52
|
|
|
52
53
|
const defaultSettings = {
|
|
53
54
|
apkadds : '',
|
|
@@ -178,6 +179,7 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
178
179
|
artifactProject,
|
|
179
180
|
artifactRegistry,
|
|
180
181
|
containerName,
|
|
182
|
+
imagePlatform,
|
|
181
183
|
imageVersion,
|
|
182
184
|
isNodeJsProject,
|
|
183
185
|
isNpmWorkspace,
|
|
@@ -226,8 +228,18 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
226
228
|
|
|
227
229
|
// build the cloudbuild.yaml from the handlebars template
|
|
228
230
|
const cloudBuildFile = './build/cloudbuild.yaml'
|
|
231
|
+
let cloudBuildSteps
|
|
232
|
+
let imagePlatformString
|
|
233
|
+
if ( !imagePlatform || ( imagePlatform.length === 1 && imagePlatform[0] === 'linux/amd64' ) ) {
|
|
234
|
+
cloudBuildSteps = cloudBuildStepsSingleArch
|
|
235
|
+
imagePlatformString = 'linux/amd64'
|
|
236
|
+
} else {
|
|
237
|
+
cloudBuildSteps = cloudBuildStepsMultiArch
|
|
238
|
+
imagePlatformString = imagePlatform.join( ',' )
|
|
239
|
+
}
|
|
240
|
+
log( `imagePlatformString => ${imagePlatformString}` )
|
|
229
241
|
const cbst = handlebars.compile( cloudBuildSteps, { noEscape : true } )
|
|
230
|
-
const cbs = cbst( { artifactProject, artifactRegistry, imageName, imageVersion, imageInfoTag, } )
|
|
242
|
+
const cbs = cbst( { artifactProject, artifactRegistry, imageName, imagePlatform : imagePlatformString, imageVersion, imageInfoTag, } )
|
|
231
243
|
fs.writeFileSync( cloudBuildFile, cbs )
|
|
232
244
|
|
|
233
245
|
// build up the cloud build command and options
|
package/src/Utils.mjs
CHANGED
|
@@ -565,10 +565,11 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
565
565
|
// if the build tools version is still undefined then assume we are using a globally installed bt
|
|
566
566
|
if ( buildToolsVersion === undefined ) {
|
|
567
567
|
const fromBuildTools = await shellCmd( 'build-tools --version' )
|
|
568
|
-
buildToolsVersion = fromBuildTools.match( /\d+\.\d+\.\d
|
|
568
|
+
buildToolsVersion = fromBuildTools.match( /\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/ )[0]
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
const containerName = closestPackageJson?.name.replace( /^@[^/]+\//, '' ) || rootPyProjectToml?.project.name
|
|
572
|
+
const imagePlatform = closestPackageJson?.leverege.imagePlatform || rootPyProjectToml?.leverege['image-platform']
|
|
572
573
|
const artifactRegistry = closestPackageJson?.leverege.registry || rootPyProjectToml?.leverege.registry
|
|
573
574
|
const artifactProject = closestPackageJson?.artifactRegistry.project || rootPyProjectToml?.artifactRegistry.project || 'unknown'
|
|
574
575
|
const packageVersion = `v${closestPackageJson?.version || rootPyProjectToml?.project.version}`
|
|
@@ -595,6 +596,7 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
595
596
|
artifactRegistry,
|
|
596
597
|
buildToolsVersion,
|
|
597
598
|
containerName,
|
|
599
|
+
imagePlatform,
|
|
598
600
|
currentDir,
|
|
599
601
|
closestPkg,
|
|
600
602
|
gitRoot,
|
|
@@ -229,6 +229,7 @@ if ( isNodeJsProject ) {
|
|
|
229
229
|
log( `
|
|
230
230
|
${chalk.green.bold( 'NodeJS Docker Information:' )}
|
|
231
231
|
NodeImage: ${chalk.green.bold( dockerInfo.imageBase || `node:${dockerInfo.nodeimage}` )}
|
|
232
|
+
Platform: ${chalk.green.bold( dockerInfo.imagePlatform )}
|
|
232
233
|
Docker Env: ${chalk.green.bold( dockerInfo.buildEnv || 'alpine' )}
|
|
233
234
|
AddedPkgs: ${chalk.green.bold( dockerInfo.apkadds )}
|
|
234
235
|
Run User: ${chalk.green.bold( dockerInfo.runuser )}
|
|
@@ -243,6 +244,7 @@ if ( isPythonProject ) {
|
|
|
243
244
|
log( `
|
|
244
245
|
${chalk.green.bold( 'Python Docker Information:' )}
|
|
245
246
|
BaseImage: ${chalk.green.bold( dockerInfo.imageBase || `node:${dockerInfo.nodeimage}` )}
|
|
247
|
+
Platform: ${chalk.green.bold( dockerInfo.imagePlatform )}
|
|
246
248
|
Python Ver: ${chalk.green.bold( dockerInfo.pythonVersion )}
|
|
247
249
|
Run User: ${chalk.green.bold( dockerInfo.runuser )}
|
|
248
250
|
Previous: ${chalk.yellow.bold( dockerInfo.previousBuild )}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
options:
|
|
2
|
+
machineType: E2_HIGHCPU_8
|
|
3
|
+
|
|
4
|
+
steps:
|
|
5
|
+
- name: 'gcr.io/cloud-builders/docker'
|
|
6
|
+
args: ['buildx', 'create', '--driver', 'docker-container', '--name', 'container', '--driver-opt', 'network=cloudbuild', '--buildkitd-flags', '--allow-insecure-entitlement=network.host', '--use']
|
|
7
|
+
|
|
8
|
+
- name: 'gcr.io/cloud-builders/docker'
|
|
9
|
+
args:
|
|
10
|
+
- 'buildx'
|
|
11
|
+
- 'build'
|
|
12
|
+
- '--builder=container'
|
|
13
|
+
- '--network=host'
|
|
14
|
+
- '--platform'
|
|
15
|
+
- '{{imagePlatform}}'
|
|
16
|
+
- '--cache-from'
|
|
17
|
+
- 'type=registry,ref={{imageName}}:cache,mode=max'
|
|
18
|
+
- '--cache-to'
|
|
19
|
+
- 'type=registry,ref={{imageName}}:cache,mode=max'
|
|
20
|
+
- '--tag'
|
|
21
|
+
- '{{imageName}}:{{imageInfoTag}}'
|
|
22
|
+
- '--tag'
|
|
23
|
+
- '{{imageName}}:{{imageVersion}}'
|
|
24
|
+
- '--tag'
|
|
25
|
+
- '{{imageName}}:latest'
|
|
26
|
+
- '--push'
|
|
27
|
+
- '.'
|
|
File without changes
|