@leverege/build-tools 2.45.0 → 2.46.0-beta.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.45.0",
3
+ "version": "2.46.0-beta.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -60,9 +60,12 @@
60
60
  "enquirer": "^2.4.1",
61
61
  "execa": "^8.0.1",
62
62
  "glob": "^10.3.10",
63
+ "handlebars": "^4.7.8",
64
+ "inquirer": "^9.2.14",
63
65
  "js-yaml": "^4.1.0",
64
66
  "ms": "^2.1.3",
65
67
  "npm-registry-fetch": "^16.1.0",
68
+ "package-up": "^5.0.0",
66
69
  "parse-gitignore": "^2.0.0",
67
70
  "read-pkg": "^9.0.1",
68
71
  "readline-sync": "^1.4.10",
package/src/Docker.mjs ADDED
@@ -0,0 +1,252 @@
1
+ import fs from 'node:fs'
2
+
3
+ import chalk from 'chalk'
4
+ import handlebars from 'handlebars'
5
+
6
+ import { errorExit, log, shellCmd, warning } from './Utils.mjs'
7
+
8
+ // The contents of these variables were initially located in files that live in
9
+ // the build-tools repository, but it just became simpler to pull the contents
10
+ // directly into these variables and forego the file loading.
11
+ //
12
+ const dockerfileTemplate = `
13
+ # Version {{regvers}} @ {{date}}
14
+ #
15
+ # The FROM directive sets the Base Image for subsequent instructions
16
+ FROM node:{{nodeimage}} as intermediate
17
+ ENV NODE_ENV production
18
+
19
+ RUN mkdir -p /usr/src/app
20
+ WORKDIR /usr/src/app
21
+
22
+ # Install app dependencies
23
+ COPY ./workspace/ /usr/src/app/
24
+ ENV GRPC_VERBOSITY ERROR
25
+
26
+ # --------------------------------------------------------------
27
+ # copy the ssh keys into place, npm install, and remove them
28
+ # --------------------------------------------------------------
29
+
30
+ # Install packages to install private repos with ssh keys
31
+ COPY ./.npmrc /usr/src/app/.npmrc
32
+ RUN apk --no-cache add openssh-client && \
33
+ apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
34
+ libstdc++ linux-headers make {{apkadds}} && \
35
+ npm install -g npm@10 && \
36
+ npm ci --only=production --ignore-scripts --no-optional {{npmlogging}} && \
37
+ rm -f /usr/src/app/.npmrc /root/.ssh/*
38
+
39
+ # --------------------------------------------------------------
40
+ # On to the real build now, the thing before was just an intermediate container
41
+ # --------------------------------------------------------------
42
+
43
+ FROM node:{{nodeimage}}
44
+
45
+ # Install tini for PID 1 and replace shell with bash so we can source files
46
+ RUN apk update && \
47
+ apk add --no-cache bash curl tini vim {{apkadds}} && \
48
+ npm install -g npm@10 && \
49
+ rm /bin/sh && ln -s /bin/bash /bin/sh && \
50
+ mkdir -p /usr/src/app /tmp/levlog && \
51
+ chown node:node /usr/src/app
52
+
53
+ {{pluginfile}}
54
+
55
+ ENTRYPOINT [ "/sbin/tini", "--" ]
56
+ WORKDIR /usr/src/app
57
+
58
+ COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
59
+
60
+ USER {{runuser}}
61
+ COPY ./bashrc /home/node/.bashrc
62
+ CMD [ "/bin/bash", "-c", "node index.js" ]`
63
+
64
+ const pluginTemplate = `
65
+ # Dockerfile.plugin - optionally extend the service Docker image
66
+ #
67
+ # This file may be used to run additional docker commands during the image
68
+ # build process without needing to maintain a local custom Dockerfile. For
69
+ # example, uncommenting the following docker RUN command will cause the
70
+ # curl and vim packages to be added to the deployed image thus making them
71
+ # available from the pod's command line on k8s:
72
+ #
73
+ # RUN apk update && apk add --no-cache curl vim
74
+ #
75
+ # Keep in mind that the Alpine Linux base image is used to keep image
76
+ # footprints small, so adding packages "just because" is not considered
77
+ # a best practice.
78
+ `
79
+
80
+ const bashrcTemplate = `
81
+ #!/bin/bash
82
+ #
83
+ alias h=history
84
+
85
+ alias ls='ls -CF --color=auto'
86
+ alias ll='ls -lh'
87
+ alias lla='ls -lha'
88
+ alias glep='grep -l -s'
89
+ alias m=less
90
+ alias menv='env | sort | less'
91
+
92
+ alias whatsmyip='wget -qO- ifconfig.co'
93
+
94
+ alias err='wget -q -O- localhost:5111/logLevel/error'
95
+ alias wrn='wget -q -O- localhost:5111/logLevel/warn'
96
+ alias inf='wget -q -O- localhost:5111/logLevel/info'
97
+ alias dbg='wget -q -O- localhost:5111/logLevel/debug'
98
+ alias trc='wget -q -O- localhost:5111/logLevel/trace'
99
+
100
+ socks()
101
+ {
102
+ netstat -ant | awk '{print }' | sort | uniq -c | sort -n
103
+ }
104
+
105
+ cmetrics()
106
+ {
107
+ wget -qO- localhost:5111/metrics
108
+ }
109
+
110
+ cmstat()
111
+ {
112
+ wget -qO- localhost:5111${1}
113
+ }
114
+
115
+ cmclear()
116
+ {
117
+ cmstat /status/clear
118
+ }
119
+ `
120
+
121
+ // Just uses the old dockreate of formatting the date.
122
+ const dateTimestamp = await shellCmd( 'date +%Y%m%d-%H%M' )
123
+
124
+ const defaultSettings = {
125
+ apkadds : '',
126
+ date : dateTimestamp,
127
+ nodeimage : 'iron-alpine',
128
+ npmlogging : '--silent',
129
+ pluginfile : '# NO PLUGIN',
130
+ regvers : 'package.version',
131
+ runuser : 'node',
132
+ }
133
+
134
+ const previousFile = './docker/.previous'
135
+
136
+ const getPreviousBuild = () => {
137
+ return fs.existsSync( previousFile ) ? fs.readFileSync( previousFile ) : 'FIRST BUILD'
138
+ }
139
+
140
+ const setPreviousBuild = ( version ) => {
141
+ fs.writeFileSync( previousFile, version )
142
+ }
143
+
144
+ const generateDockerfile = ( settings = defaultSettings ) => {
145
+
146
+ log( chalk.green.bold( 'Validating the docker structure\n' ) )
147
+
148
+ // Ensure the presence of the docker dir with plugin and bashrc - this code
149
+ // could probably be tightened up a little.
150
+ try {
151
+ fs.readdirSync( './docker' )
152
+ } catch ( err ) {
153
+ warning( 'creating the missing ./docker directory' )
154
+ fs.mkdirSync( './docker' ) // TODO: blindly assumes the mkdir succeeds
155
+ }
156
+
157
+ const bashrcFile = './docker/bashrc'
158
+ if ( !fs.existsSync( bashrcFile ) ) {
159
+ warning( `creating the missing ${bashrcFile} file in the docker directory` )
160
+ fs.writeFileSync( bashrcFile, bashrcTemplate )
161
+ }
162
+
163
+ const dockerfilePlugin = './docker/Dockerfile.plugin'
164
+ if ( !fs.existsSync( dockerfilePlugin ) ) {
165
+ warning( `creating the missing ${dockerfilePlugin} file in the docker directory` )
166
+ fs.writeFileSync( dockerfilePlugin, pluginTemplate )
167
+ }
168
+
169
+ try {
170
+ const build = fs.readdirSync( './build' )
171
+ if ( build.length === 0 ) {
172
+ errorExit( `***ERROR: the build dir is empty - ${chalk.yellow( 'run npm build' )}` )
173
+ }
174
+ } catch ( err ) {
175
+ errorExit( `***ERROR: expected the ./build directory to exist - ${chalk.yellow( 'run npm build' )}` )
176
+ }
177
+
178
+ // At this point the plugin template better exist.
179
+ if ( fs.existsSync( dockerfilePlugin ) ) {
180
+ defaultSettings.pluginfile = fs.readFileSync( dockerfilePlugin )
181
+ } else {
182
+ errorExit( `***ERROR: something went wrong with ${dockerfilePlugin} plugin creation` )
183
+ }
184
+
185
+ const compiled = handlebars.compile( dockerfileTemplate )
186
+ const replaced = compiled( settings )
187
+ const dockerfile = './docker/Dockerfile'
188
+ try {
189
+ fs.writeFileSync( dockerfile, replaced )
190
+ } catch ( err ) {
191
+ errorExit( `***ERROR: failed to write ${dockerfile}\n${err}` )
192
+ }
193
+
194
+ const previousBuild = getPreviousBuild()
195
+ const dockerInfo = { dockerfile, previousBuild, ...defaultSettings }
196
+ delete dockerInfo.pluginfile
197
+ return dockerInfo
198
+ }
199
+
200
+ const formCloudBuildBucketName = ( artifactProject ) => {
201
+ return `gs://${artifactProject}_cloudbuild`
202
+ }
203
+
204
+ const validateCloudBuildBucket = async ( artifactProject ) => {
205
+ const bucketName = formCloudBuildBucketName( artifactProject )
206
+ log( chalk.green.bold( `Verifying the build bucket exists => ${bucketName}\n` ) )
207
+ try {
208
+ await shellCmd( `gsutil ls -p ${artifactProject} -b ${bucketName}` )
209
+ } catch ( error ) {
210
+ errorExit( `***Error: from Docker.validateCloudBuildBucket\n\n${chalk.bold.yellow( error )}` )
211
+ }
212
+ }
213
+
214
+ const buildContainerImage = async ( { artifactProject, artifactRegistry, containerName, imageVersion } ) => {
215
+ const cloudBuildWorkspace = './docker/workspace'
216
+
217
+ if ( fs.existsSync( cloudBuildWorkspace ) ) {
218
+ fs.renameSync( cloudBuildWorkspace, `${cloudBuildWorkspace}-junk` )
219
+ fs.rm( `${cloudBuildWorkspace}-junk`, { recursive : true }, ( err ) => {} ) // fire and forget
220
+ }
221
+
222
+ fs.mkdirSync( cloudBuildWorkspace )
223
+
224
+ fs.cpSync( './build', './docker/workspace', { recursive : true } )
225
+ fs.cpSync( `${process.env.HOME}/.npmrc`, './docker/.npmrc' )
226
+ fs.cpSync( './package.json', './docker/workspace/package.json' )
227
+ fs.renameSync( './package-lock.json', './docker/workspace/package-lock.json' )
228
+
229
+ setPreviousBuild( imageVersion ) // update docker/.previous file
230
+
231
+ const gcloudBuild = `time gcloud builds submit --project ${artifactProject}`
232
+ const gcloudLogs = `--gcs-log-dir ${formCloudBuildBucketName( artifactProject )}/log`
233
+ const gcloudTags = `--tag ${artifactRegistry}/images/${containerName}:${imageVersion}`
234
+
235
+ log( chalk.green.bold( `
236
+ *** Submitting Build ***
237
+ ${gcloudBuild} \\
238
+ ${gcloudLogs} \\
239
+ ${gcloudTags}
240
+ ` ) )
241
+
242
+ await shellCmd( `${gcloudBuild} ${gcloudLogs} ${gcloudTags} ./docker`, { stdio : 'inherit' } )
243
+ }
244
+
245
+ export default {
246
+ getPreviousBuild,
247
+ setPreviousBuild,
248
+ generateDockerfile,
249
+ formCloudBuildBucketName,
250
+ validateCloudBuildBucket,
251
+ buildContainerImage,
252
+ }
package/src/Utils.mjs CHANGED
@@ -2,6 +2,9 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs'
2
2
 
3
3
  import chalk from 'chalk'
4
4
  import { $ } from 'execa'
5
+ import inquirer from 'inquirer'
6
+ import { glob } from 'glob'
7
+ import { packageUp } from 'package-up'
5
8
  import YAML from 'js-yaml'
6
9
 
7
10
  const debugEnabled = process.env.BUILD_TOOLS_DEBUG === '1'
@@ -19,12 +22,34 @@ export const condir = ( obj, text = '' ) => {
19
22
  export const debug = ( obj, text ) => {
20
23
  if ( debugEnabled ) { condir( obj, text ) }
21
24
  }
25
+ export const warning = ( warningText ) => {
26
+ const fullWarning = `***WARNING: ${warningText}`
27
+ console.error( `\n${chalk.yellow.bold( fullWarning )}` )
28
+ }
29
+
22
30
  export const errorExit = ( error, opts = { errorCode : 1 } ) => {
23
31
  console.error( `\n${chalk.red.bold( error )}\n` )
24
32
  if ( opts?.errorCode ) { process.exit( opts.errorCode ) }
25
33
  }
26
34
  /* eslint-enable no-console */
27
35
 
36
+ /**
37
+ * General "yes" to proceed function.
38
+ */
39
+ export const proceed = async ( query = 'Do you wish to proceed?' ) => {
40
+ await inquirer.prompt( [
41
+ {
42
+ type : 'confirm',
43
+ name : 'proceed',
44
+ message : query,
45
+ default : true,
46
+ }
47
+ ]
48
+ ).then( ( answer ) => {
49
+ if ( !answer.proceed ) { process.exit( 0 ) }
50
+ } )
51
+ }
52
+
28
53
  export const shellCmd = async ( cmdstr, opts = {} ) => {
29
54
  try {
30
55
  // due to the escaping rules we pull apart the cmdstr and invoke $ using
@@ -85,42 +110,165 @@ export const parseJsonFile = async ( jsonFile ) => {
85
110
  throw new Error( `${error} in ${jsonFile}` )
86
111
  }
87
112
  }
88
- throw new Error( `File ${jsonFile} does not exist` )
113
+ throw new Error( `Utils.parseJsonFile: file ${jsonFile} does not exist in ${process.cwd()}` )
89
114
  /* eslint-enable security/detect-non-literal-fs-filename */
90
115
  }
91
116
 
92
117
  // Parses the ./package.json file and verifies there is a properly formatted
93
118
  // leverege.registry section present.
119
+ const deprecated = ( opts ) => {
120
+ log( chalk.red.bold( `\n ***DEPRECATED: ${opts.deprecationError}` ) )
121
+ log( chalk.white( opts.deprecationInfo ) )
122
+ process.exit( 1 )
123
+ }
124
+
94
125
  export const parsePackageJson = async ( packageFileName ) => {
95
126
  const packageJson = await parseJsonFile( packageFileName )
96
127
 
128
+ // deprecation checks are here to ease the pain of upgrading older repos
97
129
  const leveregeClauseError = `leverege.registry statement, it should
98
130
  resemble something like:
99
131
 
100
132
  "leverege": {
101
- "registry": "us-docker.pkg.dev/leverege-registry/<REPO NAME>"
133
+ "registry": "us-docker.pkg.dev/leverege-registry/<registry folder>"
102
134
  },
103
135
 
104
- `
105
136
 
106
- if ( !packageJson?.leverege?.registry ) {
137
+ Where <registry folder> should be an existing folder in the artifact-registry.
138
+ `
139
+ const registry = packageJson?.leverege?.registry
140
+ if ( !registry ) {
107
141
  errorExit( `Error: package.json is missing a proper ${leveregeClauseError}` )
108
142
  }
109
143
 
110
- const artifacts = packageJson.leverege.registry.split( '/' )
111
- if ( artifacts.length !== 3 ) {
144
+ const registryComponents = registry.split( '/' )
145
+ if ( registryComponents.length !== 3 ) {
112
146
  errorExit( `Error: package.json has a malformed ${leveregeClauseError}` )
113
147
  }
114
148
 
115
- return {
116
- artifactRegistry : {
117
- registry : packageJson.leverege.registry,
118
- region : artifacts[0],
119
- project : artifacts[1],
120
- repository : artifacts[2],
121
- },
122
- ...packageJson,
149
+ const [ region, project, repository ] = registryComponents
150
+ const artifactRegistry = { region, project, repository }
151
+
152
+ // DEPRECATED: leverege.project
153
+ if ( packageJson?.leverege?.project ) {
154
+ const removeLine = `"project": "${packageJson.leverege.project}",`
155
+
156
+ const deprecationError = 'leverege.project is no longer supported'
157
+ const deprecationInfo = `
158
+ Setting the project in the package.json leverege section was used for builds
159
+ being stored in the deprecated GCP container registry. Remove the deprecated
160
+ leverege.project setting from package.json and try again.
161
+
162
+ "leverege": {
163
+ ${chalk.red.bold( removeLine )}
164
+ ...
165
+ }
166
+ `
167
+ deprecated( { deprecationError, deprecationInfo } )
168
+ }
169
+
170
+ // DEPRECATED: leverege.container
171
+ if ( packageJson?.leverege?.container ) {
172
+ const removeLine = `"container": "${packageJson.leverege.container}",`
173
+
174
+ const deprecationError = 'leverege.container is no longer supported'
175
+ const deprecationInfo = `
176
+ Setting the container name explicitly from the package.json leverge block
177
+ is no longer supported. The container name will be automatically derived
178
+ from the git repository's remote root, which is the default behavior. Remove
179
+ the container line from the leverege section in package.json and try again.
180
+
181
+ "leverege": {
182
+ ${chalk.red.bold( removeLine )}
183
+ ...
184
+ }
185
+ `
186
+ deprecated( { deprecationError, deprecationInfo } )
187
+ }
188
+
189
+ // DEPRECATED: leverege.nodeimg
190
+ if ( packageJson?.leverege?.nodeimg ) {
191
+ const removeLine = `"nodeimg": "${packageJson.leverege.nodeimg}",`
192
+
193
+ const deprecationError = 'leverege.nodeimg is no longer supported'
194
+ const deprecationInfo = `
195
+ Setting the node base image using the nodeimg statement in package.json is no
196
+ longer supported. By default the actual node image version will be defaulted
197
+ by this script and will rarely need to be a specific version. Remove the
198
+ nodeimg line from the leverege section in package.json and try again.
199
+
200
+ "leverege": {
201
+ ${chalk.red.bold( removeLine )}
202
+ ...
203
+ }
204
+ `
205
+ deprecated( { deprecationError, deprecationInfo } )
206
+ }
207
+
208
+ // DEPRECATED: leverege.artifact
209
+ if ( packageJson?.leverege?.artifact ) {
210
+ const removeLine = `"artifact": "${packageJson.leverege.artifact}",`
211
+ const replaceLine = `"registry": "us-docker.pkg.dev/leverege-registry/${packageJson.leverege.artifact}",`
212
+
213
+ const deprecationError = 'leverege.artifact is no longer supported'
214
+ const deprecationInfo = `
215
+ Setting the registry folder via the ${chalk.yellow.bold( 'artifact' )} statement is no longer supported.
216
+ Instead use the ${chalk.green.bold( 'leverege.registry' )} setting to specify the full artifact registry
217
+ and folder used for storing the docker image. Replace the artifact line with the
218
+ full registry path in package.json and try again.
219
+
220
+ "leverege": {
221
+ ${chalk.red.bold( removeLine )}
222
+ ${chalk.green.bold( replaceLine )}
223
+ ...
123
224
  }
225
+ `
226
+ deprecated( { deprecationError, deprecationInfo } )
227
+ }
228
+
229
+ // DEPRECATED: leverege.nodeops
230
+ if ( packageJson?.leverege?.nodeops ) {
231
+ const removeLine = `"nodeops": "${packageJson.leverege.nodeops}",`
232
+
233
+ const deprecationError = 'leverege.nodeops is no longer supported'
234
+ const deprecationInfo = `
235
+ Setting the hard coded node options on the image is no longer supported. The
236
+ better approach is to add ${chalk.green.bold( 'NODE_OPTIONS' )} to the config section of the chart's
237
+ values.yaml to allow downstream users to easily tune the options as needed.
238
+ Remove the nodeops line from the leverege section in package.json and try again.
239
+
240
+ "leverege": {
241
+ ${chalk.red.bold( removeLine )}
242
+ ...
243
+ }
244
+ `
245
+ deprecated( { deprecationError, deprecationInfo } )
246
+ }
247
+
248
+ // DEPRECATED: old reference to ./dist should be ./build
249
+ const { build, clean, dockerize, } = packageJson.scripts
250
+
251
+ if ( build.match( 'dist' ) || clean.match( 'dist' ) || dockerize.match( 'dockreate|cd docker' ) ) {
252
+ const deprecationError = `
253
+
254
+ Update the npm build, clean and dockerize scripts to use ./build instead of
255
+ the old ./dist directory, and docker-to-registry instead of the deprecated
256
+ dockreate script - note there is no longer a need to change dir into docker
257
+ in the dockerize script.
258
+ `
259
+ const deprecationInfo = `
260
+ "scripts": {
261
+ "build": "npm run clean && mkdir ./build && cp -r ./src/* ./build",
262
+ ...
263
+ "clean": "rm -fr coverage build",
264
+ "dockerize": "npm run build && docker-to-registry",
265
+ ...
266
+ },
267
+ `
268
+
269
+ deprecated( { deprecationError, deprecationInfo } )
270
+ }
271
+ return { artifactRegistry, ...packageJson }
124
272
  }
125
273
 
126
274
  export const parseHelmChart = async ( helmroot ) => {
@@ -137,3 +285,61 @@ export const parseHelmChart = async ( helmroot ) => {
137
285
  }
138
286
  } )
139
287
  }
288
+
289
+ export const analyzeRepository = async () => {
290
+ const gitRoot = await getGitRootDirectory()
291
+ const subPkgs = await glob( `${gitRoot}/packages/**/package.json`, { ignore : '/**/node_modules/**' } )
292
+ const isMonoRepo = subPkgs?.length > 0
293
+
294
+ let rootPackageJson
295
+ try {
296
+ rootPackageJson = await parseJsonFile( `${gitRoot}/package.json` )
297
+ } catch ( error ) {
298
+ rootPackageJson = { invalid : true, error : 'invalid or non-existent root package.json file' }
299
+ }
300
+ const isNpmWorkspace = subPkgs?.length > 0
301
+
302
+ log( chalk.green.bold( '\nParsing and analyzing the package.json file\n' ) )
303
+ let closestPackageJson
304
+ try {
305
+ closestPackageJson = await parsePackageJson( './package.json' )
306
+ } catch ( error ) {
307
+ errorExit( error )
308
+ }
309
+ const containerName = closestPackageJson.name
310
+ const artifactProject = closestPackageJson.artifactRegistry.project
311
+ const artifactRegistry = closestPackageJson.leverege.registry
312
+
313
+ const currentDir = process.cwd()
314
+ const closestPkg = await packageUp()
315
+
316
+ // get the name of the current workspace, if we're in one
317
+ let wsName
318
+ try {
319
+ wsName = await shellCmd( 'npm exec -c pwd -ws' )
320
+ } catch ( err ) { }
321
+
322
+ let gitRemote
323
+ try {
324
+ gitRemote = await shellCmd( 'git config --get remote.origin.url' )
325
+ } catch ( err ) { }
326
+
327
+ // TODO: Add in Define VERBOSE_DOCKREATE_NPM="yes" for verbose build logging
328
+ // TODO: Validity check for version and package.json
329
+
330
+ return {
331
+ artifactProject,
332
+ artifactRegistry,
333
+ containerName,
334
+ currentDir,
335
+ closestPkg,
336
+ gitRoot,
337
+ gitRemote,
338
+ isMonoRepo,
339
+ isNpmWorkspace,
340
+ rootPackageJson,
341
+ closestPackageJson,
342
+ subPkgs,
343
+ wsName,
344
+ }
345
+ }
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * docker-to-registry will...
4
+ */
5
+ import chalk from 'chalk'
6
+
7
+ import {
8
+ debug, log,
9
+ errorExit,
10
+ analyzeRepository,
11
+ proceed,
12
+ shellCmd } from './Utils.mjs'
13
+
14
+ import docker from './Docker.mjs'
15
+
16
+ // refresh-npm-token does not throw so no need to try, but it emits in debug
17
+ const refreshErr = await shellCmd( 'refresh-npm-token' )
18
+ if ( refreshErr && !process.env.BUILD_TOOLS_DEBUG ) {
19
+ errorExit( `***Error: npm token refresh failed\n\n${refreshErr}` )
20
+ }
21
+
22
+ // Expected to be invoked like docker-to-registry v1.2.3
23
+ const imageVersion = process.argv[2]
24
+ const willGitTag = imageVersion.match( /^v\d+\.\d+\.\d+$/ )
25
+ const tagInfo = willGitTag ?
26
+ chalk.yellow.bold( 'will be git tagged' ) :
27
+ chalk.red( 'BETA RELEASE WILL NOT BE GIT TAGGED' )
28
+
29
+ const repoDescr = await analyzeRepository()
30
+ debug( { repoDescr }, '<==The Repo Description' )
31
+
32
+ const dockerInfo = await docker.generateDockerfile()
33
+ debug( { dockerInfo }, '<==The Docker Info' )
34
+
35
+ const { artifactProject, artifactRegistry, containerName } = repoDescr
36
+
37
+ await docker.validateCloudBuildBucket( artifactProject )
38
+
39
+ const registryFolder = `${artifactRegistry}/images/${containerName}`
40
+
41
+ // Update the dependencies...
42
+ log( chalk.green.bold( 'Updating dependencies and workspace...' ) )
43
+ await shellCmd( 'npm install', { stdio : 'inherit' } )
44
+
45
+ // Give the summary and the user a chance to proceed or not
46
+ log( `
47
+ ${chalk.green.bold( 'Build Information:' )}
48
+ Container: ${chalk.green.bold( containerName )}
49
+ Version: ${chalk.green.bold( imageVersion )} ${tagInfo}
50
+ Registry: ${chalk.green.bold( artifactRegistry )}
51
+ Image Folder: ${chalk.yellow.bold( registryFolder )}
52
+ Monorepo: ${chalk.green.bold( repoDescr.isMonoRepo )}
53
+ NPM Workspace: ${chalk.green.bold( repoDescr.isNpmWorkspace )}
54
+
55
+ ${chalk.green.bold( 'Docker Information:' )}
56
+ NodeImage: ${chalk.green.bold( dockerInfo.nodeimage )}
57
+ AddedPkgs: ${chalk.green.bold( dockerInfo.apkadds )}
58
+ Run User: ${chalk.green.bold( dockerInfo.runuser )}
59
+ Previous: ${chalk.yellow.bold( dockerInfo.previousBuild )}
60
+ DateStamp: ${chalk.green.bold( dockerInfo.date )}
61
+ NPM Logs: ${chalk.green.bold( dockerInfo.npmlogging )}
62
+ ` )
63
+
64
+ await proceed()
65
+
66
+ if ( repoDescr.isNpmWorkspace ) {
67
+ log( chalk.yellow.bold( 'Generating an NPM workspace package-lock.json file' ) )
68
+ await shellCmd( 'npm install --package-lock-only --workspaces false', { stdio : 'inherit' } )
69
+ }
70
+
71
+ await docker.buildContainerImage( { artifactProject, artifactRegistry, containerName, imageVersion } )
@@ -1,15 +1,15 @@
1
1
  postgresql:
2
2
  postgresqlExtendedConf:
3
- maxWorkerProcesses: 8
4
- maxParallelWorkers: 8
5
- maxConnections: 500
6
- sharedBuffers: 2GB
7
- effectiveCacheSize: 6GB
8
- maintenanceWorkMem: 1GB
9
- workMem: 20MB
10
- idle_in_transaction_session_timeout: 30000 # 30ms timeout
11
- maxWalSize: 2GB
12
- walKeepSegments: 64
3
+ effectiveCacheSize: 6GB # 524288 8kB
4
+ idle_in_transaction_session_timeout: 30000 # 0 ms
5
+ maintenanceWorkMem: 1GB # 65536 kB
6
+ maxConnections: 500 # 100
7
+ maxParallelWorkers: 8 # 32
8
+ maxWalSize: 2GB # 80 MB
9
+ maxWorkerProcesses: 8 # 32
10
+ sharedBuffers: 2GB # 16384 8kB
11
+ walKeepSegments: 64 # deprecated
12
+ workMem: 20MB # 4096 kB
13
13
 
14
14
  resources:
15
15
  requests: