@leverege/build-tools 2.63.0 → 2.63.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.63.0",
3
+ "version": "2.63.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -60,7 +60,6 @@
60
60
  "author": "Leverege Devs",
61
61
  "license": "SEE LICENSE IN LICENSE.md",
62
62
  "dependencies": {
63
- "@google-cloud/artifact-registry": "^3.5.0",
64
63
  "@leverege/jsdoc-template": "^1.0.1",
65
64
  "chalk": "^5.4.1",
66
65
  "command-line-args": "^6.0.1",
@@ -3,7 +3,8 @@
3
3
  // A simple utility for easily building CNPG based psql images. The resultant
4
4
  // image will contain PostgreSQL, the JS query and Timescale extensions, and
5
5
  // the extensions that are required by CNPG like barman, pgaudit, pgvector and
6
- // pg-failover-slots.
6
+ // pg-failover-slots. The docker image will be built using GCP Cloud Build in
7
+ // order to create an image that is k8s friendly.
7
8
  //
8
9
  // Latest Versions:
9
10
  // postgres => https://www.postgresql.org/
@@ -11,6 +12,7 @@
11
12
  // CNPG images => https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql
12
13
 
13
14
  import fs from 'node:fs'
15
+ import os from 'node:os'
14
16
  import path from 'node:path'
15
17
 
16
18
  import chalk from 'chalk'
@@ -122,25 +124,22 @@ const buildAndPushImage = async () => {
122
124
  const renderedDockerfile = template( { PG_VERSION } )
123
125
  debug( { renderedDockerfile }, '<==Dockerfile' )
124
126
 
125
- // Write the Dockerfile to a temporary location
126
- const buildDir = './build-tmp'
127
- fs.mkdirSync( buildDir )
128
- const dockerfilePath = path.resolve( `${buildDir}/Dockerfile` )
129
- fs.writeFileSync( dockerfilePath, renderedDockerfile )
130
-
131
- // Build the image
132
- log( chalk.yellow( '\nBuilding Docker image...' ) )
133
- const cloudBuildSubmit = 'gcloud builds submit --project leverege-registry'
134
- const cloudBuildLog = '--gcs-log-dir gs://leverege-registry_cloudbuild/log'
135
- const imageTag = `--tag ${LEVEREGE_IMAGE_NAME_WITH_TAG}`
136
- await shellCmd( `${cloudBuildSubmit} ${cloudBuildLog} ${imageTag} ${buildDir}`, { stdio : 'inherit' } )
137
-
138
- // Push the image
139
- //log( chalk.green( '\nPushing Docker image...' ) )
140
- //await shellCmd( `docker push ${LEVEREGE_IMAGE_NAME_WITH_TAG}`, { stdio : 'inherit' } )
141
-
142
- // Clean up the temporary Dockerfile
143
- fs.rmdirSync( buildDir, { recursive : true } )
127
+ // Create a temporary directory to build from
128
+ const buildDir = fs.mkdtempSync( path.join( os.tmpdir(), 'docker-build-' ) )
129
+ const dockerfilePath = path.join( buildDir, 'Dockerfile' )
130
+
131
+ try {
132
+ fs.writeFileSync( dockerfilePath, renderedDockerfile )
133
+
134
+ log( chalk.yellow( '\nBuilding Docker image...' ) )
135
+ const cloudBuildSubmit = 'gcloud builds submit --project leverege-registry'
136
+ const cloudBuildLog = '--gcs-log-dir gs://leverege-registry_cloudbuild/log'
137
+ const imageTag = `--tag ${LEVEREGE_IMAGE_NAME_WITH_TAG}`
138
+ await shellCmd( `${cloudBuildSubmit} ${cloudBuildLog} ${imageTag} ${buildDir}`, { stdio : 'inherit' } )
139
+ } finally {
140
+ // Ensure cleanup even if the build fails
141
+ fs.rmSync( buildDir, { recursive : true, force : true } )
142
+ }
144
143
  }
145
144
 
146
145
  // Main execution flow
@@ -100,7 +100,7 @@ if ( args.init ) {
100
100
  errorExit( `\n***ERROR: ${args.compass} compass file already exists - not overwriting` )
101
101
  }
102
102
 
103
- const copyOut = await shellCmd( `cp ${BUILD_TOOLS_ROOT}/chart-compass.yaml ${args.compass}` )
103
+ await shellCmd( `cp ${BUILD_TOOLS_ROOT}/chart-compass.yaml ${args.compass}` )
104
104
  log( '\nBootstrapped a new chart compass defition => ', chalk.green.bold( args.compass ) )
105
105
  process.exit( 0 )
106
106
  }