@leverege/build-tools 2.59.0-beta.4 → 2.59.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 +8 -5
- package/src/Docker.mjs +133 -14
- package/src/Utils.mjs +7 -1
- package/src/build-cnpg-image.mjs +167 -0
- package/src/circleate.sh +2 -2
- package/src/docker-to-registry.mjs +2 -4
- package/src/generate-docs-conf.json +41 -0
- package/src/generate-docs.mjs +51 -0
- package/src/helm-charts/cnpg-operator/helmup.plugin +7 -7
- package/src/helm-charts/elasticsearch8/helmup.plugin +1 -1
- package/src/helm-charts/prom-operator/helmup.plugin +1 -1
- package/src/helm-charts/redis/helmup.plugin +1 -1
- package/src/helm-charts/velero/helmup.plugin +1 -1
- package/src/helm-charts/velero/velero-local.yaml +4 -0
- package/src/helmup.sh +31 -4
- package/src/k8cryo.sh +0 -20
- package/src/tag-release.mjs +0 -692
- package/src/templates/bashrcTemplate.hbs +0 -46
- package/src/templates/cloudBuildSteps.hbs +0 -13
- package/src/templates/dockerfileTemplate.hbs +0 -86
- /package/src/{cnpg-backup.mjs → snapshot-cnpg.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.59.
|
|
3
|
+
"version": "2.59.1",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"encrypt-secrets": "src/encrypt-secrets.sh",
|
|
28
28
|
"firebaseDeploy": "src/firebaseDeploy.mjs",
|
|
29
29
|
"firebaseServe": "src/firebaseServe.mjs",
|
|
30
|
+
"generate-docs": "src/generate-docs.mjs",
|
|
30
31
|
"getfbcfg": "src/getfbcfg.mjs",
|
|
31
32
|
"getjson": "src/getjson.mjs",
|
|
32
33
|
"git-tar": "src/git-tar.sh",
|
|
@@ -59,8 +60,9 @@
|
|
|
59
60
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
60
61
|
"dependencies": {
|
|
61
62
|
"@google-cloud/artifact-registry": "^3.5.0",
|
|
63
|
+
"@leverege/jsdoc-template": "^1.0.1",
|
|
62
64
|
"ansi-colors": "^4.1.3",
|
|
63
|
-
"chalk": "^5.
|
|
65
|
+
"chalk": "^5.4.1",
|
|
64
66
|
"command-line-args": "^6.0.1",
|
|
65
67
|
"command-line-usage": "^7.0.3",
|
|
66
68
|
"deepmerge": "^4.3.1",
|
|
@@ -68,8 +70,9 @@
|
|
|
68
70
|
"execa": "^9.5.2",
|
|
69
71
|
"glob": "^11.0.0",
|
|
70
72
|
"handlebars": "^4.7.8",
|
|
71
|
-
"inquirer": "^12.
|
|
73
|
+
"inquirer": "^12.3.0",
|
|
72
74
|
"js-yaml": "^4.1.0",
|
|
75
|
+
"jsdoc": "^4.0.4",
|
|
73
76
|
"ms": "^2.1.3",
|
|
74
77
|
"npm-registry-fetch": "^18.0.2",
|
|
75
78
|
"package-up": "^5.0.0",
|
|
@@ -78,10 +81,10 @@
|
|
|
78
81
|
"readline-sync": "^1.4.10",
|
|
79
82
|
"semver": "^7.6.3",
|
|
80
83
|
"simple-git": "^3.27.0",
|
|
81
|
-
"zx": "^8.
|
|
84
|
+
"zx": "^8.3.0"
|
|
82
85
|
},
|
|
83
86
|
"devDependencies": {
|
|
84
87
|
"@leverege/eslint-config-leverege": "^5.0.1",
|
|
85
|
-
"npm": "^
|
|
88
|
+
"npm": "^11.0.0"
|
|
86
89
|
}
|
|
87
90
|
}
|
package/src/Docker.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import url from 'node:url'
|
|
4
2
|
|
|
5
3
|
import chalk from 'chalk'
|
|
6
4
|
import handlebars from 'handlebars'
|
|
@@ -15,15 +13,80 @@ import {
|
|
|
15
13
|
warning
|
|
16
14
|
} from './Utils.mjs'
|
|
17
15
|
|
|
18
|
-
const DIRNAME = path.dirname( url.fileURLToPath( import.meta.url ) )
|
|
19
|
-
|
|
20
16
|
// TODO: change default to node 22 (jod) after 01/01/25
|
|
21
|
-
const dockerfileNodeVersion =
|
|
17
|
+
const dockerfileNodeVersion = 'jod-alpine'
|
|
22
18
|
|
|
23
19
|
// The contents of these variables were initially located in files that live in
|
|
24
20
|
// the build-tools repository, but it just became simpler to pull the contents
|
|
25
21
|
// directly into these variables and forego the file loading.
|
|
26
22
|
//
|
|
23
|
+
const dockerfileTemplate = `
|
|
24
|
+
# Version {{regvers}} @ {{date}}
|
|
25
|
+
#
|
|
26
|
+
# The FROM directive sets the Base Image for subsequent instructions
|
|
27
|
+
FROM node:{{nodeimage}} as intermediate
|
|
28
|
+
ENV NODE_ENV production
|
|
29
|
+
ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
|
|
30
|
+
|
|
31
|
+
RUN mkdir -p /usr/src/app
|
|
32
|
+
WORKDIR /usr/src/app
|
|
33
|
+
|
|
34
|
+
# Install app dependencies
|
|
35
|
+
COPY ./workspace/ /usr/src/app/
|
|
36
|
+
ENV GRPC_VERBOSITY ERROR
|
|
37
|
+
|
|
38
|
+
# --------------------------------------------------------------
|
|
39
|
+
# copy the ssh keys into place, npm install, and remove them
|
|
40
|
+
# --------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
# Install packages to install private repos with ssh keys
|
|
43
|
+
COPY ./.npmrc \${NPM_CONFIG_USERCONFIG}
|
|
44
|
+
RUN apk --no-cache add openssh-client && \
|
|
45
|
+
apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
|
|
46
|
+
libstdc++ linux-headers make {{apkadds}} && \
|
|
47
|
+
npm install -g {{npmVersion}}
|
|
48
|
+
|
|
49
|
+
{{preInstallPluginfile}}
|
|
50
|
+
|
|
51
|
+
# Use SKIP_PREPARE to disable hook-and-release from running
|
|
52
|
+
ENV SKIP_PREPARE=true
|
|
53
|
+
|
|
54
|
+
# Do the clean install and remove the npm token and ssh keys from the image
|
|
55
|
+
RUN npm ci --only=production --no-optional {{npmlogging}} && \
|
|
56
|
+
rm -f \${NPM_CONFIG_USERCONFIG} /root/.ssh/*
|
|
57
|
+
|
|
58
|
+
# --------------------------------------------------------------
|
|
59
|
+
# Docker Final Stage
|
|
60
|
+
# --------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
FROM node:{{nodeimage}}
|
|
63
|
+
ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
|
|
64
|
+
|
|
65
|
+
# Copy .npmrc for private registry access for access to any @leverege packages
|
|
66
|
+
COPY ./.npmrc \${NPM_CONFIG_USERCONFIG}
|
|
67
|
+
|
|
68
|
+
# Install tini for PID 1 and replace shell with bash so we can source files
|
|
69
|
+
RUN apk update && \
|
|
70
|
+
apk add --no-cache bash curl tini vim {{apkadds}} && \
|
|
71
|
+
npm install -g {{npmVersion}} && \
|
|
72
|
+
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
73
|
+
mkdir -p /usr/src/app /tmp/levlog && \
|
|
74
|
+
chown node:node /usr/src/app
|
|
75
|
+
|
|
76
|
+
# Pull in the Dockerfile.plugin file here
|
|
77
|
+
{{pluginfile}}
|
|
78
|
+
|
|
79
|
+
# Eliminate the sensitive info from the final stage image
|
|
80
|
+
RUN rm -f \${NPM_CONFIG_USERCONFIG}
|
|
81
|
+
|
|
82
|
+
ENTRYPOINT [ "/sbin/tini", "--" ]
|
|
83
|
+
WORKDIR /usr/src/app
|
|
84
|
+
|
|
85
|
+
COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
|
|
86
|
+
|
|
87
|
+
USER {{runuser}}
|
|
88
|
+
COPY ./bashrc /home/node/.bashrc
|
|
89
|
+
CMD [ "/bin/bash", "-c", "source /home/node/.bashrc && node index.js" ]`
|
|
27
90
|
|
|
28
91
|
const pluginTemplate = `
|
|
29
92
|
# Dockerfile.plugin - optionally extend the service Docker image
|
|
@@ -40,16 +103,74 @@ const pluginTemplate = `
|
|
|
40
103
|
# footprints small, so adding packages "just because" is not considered
|
|
41
104
|
# a best practice.
|
|
42
105
|
`
|
|
43
|
-
|
|
44
|
-
const bashrcTemplate =
|
|
45
|
-
|
|
106
|
+
|
|
107
|
+
const bashrcTemplate = `#!/bin/bash
|
|
108
|
+
#
|
|
109
|
+
alias h=history
|
|
110
|
+
|
|
111
|
+
alias ls='ls -CF --color=auto'
|
|
112
|
+
alias ll='ls -lh'
|
|
113
|
+
alias lla='ls -lha'
|
|
114
|
+
alias glep='grep -l -s'
|
|
115
|
+
alias m=less
|
|
116
|
+
alias menv='env | sort | less'
|
|
117
|
+
|
|
118
|
+
alias whatsmyip='wget -qO- ifconfig.co'
|
|
119
|
+
|
|
120
|
+
alias err='wget -q -O- localhost:5111/logLevel/error'
|
|
121
|
+
alias wrn='wget -q -O- localhost:5111/logLevel/warn'
|
|
122
|
+
alias inf='wget -q -O- localhost:5111/logLevel/info'
|
|
123
|
+
alias dbg='wget -q -O- localhost:5111/logLevel/debug'
|
|
124
|
+
alias trc='wget -q -O- localhost:5111/logLevel/trace'
|
|
125
|
+
|
|
126
|
+
socks()
|
|
127
|
+
{
|
|
128
|
+
netstat -ant | awk '{print }' | sort | uniq -c | sort -n
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
cmetrics()
|
|
132
|
+
{
|
|
133
|
+
wget -qO- localhost:5111/metrics
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
cmstat()
|
|
137
|
+
{
|
|
138
|
+
wget -qO- localhost:5111
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
cmclear()
|
|
142
|
+
{
|
|
143
|
+
# Future me - thinking this should call cmstat and pass in the endpoint as
|
|
144
|
+
# a parameter? Well don't do it - without escaping the dollar 1 in cmstat
|
|
145
|
+
# the port will end up being 51111, and escaping causes linting to complain
|
|
146
|
+
# about unnecessary escaping.
|
|
147
|
+
wget -qO- localhost:5111/status/clear
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
dunm() {
|
|
151
|
+
du -sh /usr/src/app/node_modules/* | sort -sh
|
|
152
|
+
}
|
|
153
|
+
`
|
|
154
|
+
const cloudBuildSteps = `
|
|
155
|
+
steps:
|
|
156
|
+
- name: 'gcr.io/cloud-builders/docker'
|
|
157
|
+
args:
|
|
158
|
+
- 'build'
|
|
159
|
+
- '--network=cloudbuild'
|
|
160
|
+
- '-t'
|
|
161
|
+
- '{{imageName}}:{{imageVersion}}'
|
|
162
|
+
- '.'
|
|
163
|
+
|
|
164
|
+
images:
|
|
165
|
+
- '{{imageName}}:{{imageVersion}}'
|
|
166
|
+
`
|
|
46
167
|
|
|
47
168
|
const defaultSettings = {
|
|
48
169
|
apkadds : '',
|
|
49
170
|
date : getDateTimestamp(),
|
|
50
|
-
nodeimage :
|
|
51
|
-
imageBase : process.env.USE_NODEJS_22 ? 'node:jod-alpine' : 'node:iron-alpine',
|
|
171
|
+
nodeimage : 'jod-alpine',
|
|
52
172
|
npmlogging : process.env.VERBOSE_NPM_LOGGING ? '--ddd' : '--silent',
|
|
173
|
+
npmVersion : 'npm@11',
|
|
53
174
|
pluginfile : '# NO PLUGIN',
|
|
54
175
|
preInstallPluginfile : '# NO PRE-INSTALL PLUGIN',
|
|
55
176
|
regvers : 'package.version',
|
|
@@ -75,7 +196,7 @@ const generateDockerfile = ( options ) => {
|
|
|
75
196
|
if ( !settings.nodeimage ) {
|
|
76
197
|
settings.nodeimage = dockerfileNodeVersion
|
|
77
198
|
}
|
|
78
|
-
|
|
199
|
+
|
|
79
200
|
// Ensure the presence of the docker dir with plugin and bashrc - this code
|
|
80
201
|
// could probably be tightened up a little.
|
|
81
202
|
try {
|
|
@@ -86,9 +207,7 @@ const generateDockerfile = ( options ) => {
|
|
|
86
207
|
}
|
|
87
208
|
|
|
88
209
|
const bashrcFile = './docker/bashrc'
|
|
89
|
-
|
|
90
|
-
// always be created or we encounter errors
|
|
91
|
-
if ( true ) { // !fs.existsSync( bashrcFile ) ) {
|
|
210
|
+
if ( !fs.existsSync( bashrcFile ) ) {
|
|
92
211
|
let bf = bashrcTemplate
|
|
93
212
|
const bashrcFilePlugin = './docker/Bashrc.plugin'
|
|
94
213
|
if ( fs.existsSync( bashrcFilePlugin ) ) {
|
package/src/Utils.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import url from 'node:url'
|
|
2
4
|
|
|
3
5
|
import chalk from 'chalk'
|
|
4
6
|
import { $ } from 'execa'
|
|
@@ -7,6 +9,10 @@ import { glob } from 'glob'
|
|
|
7
9
|
import { packageUp } from 'package-up'
|
|
8
10
|
import YAML from 'js-yaml'
|
|
9
11
|
|
|
12
|
+
// __dirname goes away with ESM so we take this approach instead and
|
|
13
|
+
// this assumes this file lives in the src dir of the build-tools repo
|
|
14
|
+
export const BUILD_TOOLS_ROOT = path.dirname( url.fileURLToPath( import.meta.url ) )
|
|
15
|
+
|
|
10
16
|
let debugEnabled = process.env.BUILD_TOOLS_DEBUG === '1'
|
|
11
17
|
|
|
12
18
|
export const enableDebug = () => { debugEnabled = true }
|
|
@@ -471,7 +477,7 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
471
477
|
await shellCmd( 'npm run build' )
|
|
472
478
|
}
|
|
473
479
|
|
|
474
|
-
const buildToolsVersion = closestPackageJson.devDependencies['@leverege/build-tools']
|
|
480
|
+
const buildToolsVersion = closestPackageJson.devDependencies['@leverege/build-tools'] || closestPackageJson.dependencies['@leverege/build-tools']
|
|
475
481
|
if ( !buildToolsVersion ) {
|
|
476
482
|
errorExit( 'Error: missing devDependency for @leverege/build-tools in package.json' )
|
|
477
483
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// A simple utility for easily building CNPG based psql images. The resultant
|
|
4
|
+
// image will contain PostgreSQL, the JS query and Timescale extensions, and
|
|
5
|
+
// the extensions that are required by CNPG like barman, pgaudit, pgvector and
|
|
6
|
+
// pg-failover-slots.
|
|
7
|
+
//
|
|
8
|
+
// Latest Versions:
|
|
9
|
+
// postgres => https://www.postgresql.org/
|
|
10
|
+
// timescale => https://docs.timescale.com/about/latest/
|
|
11
|
+
// CNPG images => https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql
|
|
12
|
+
|
|
13
|
+
import fs from 'node:fs'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
|
|
16
|
+
import chalk from 'chalk'
|
|
17
|
+
import cliArgs from 'command-line-args'
|
|
18
|
+
import cliHelp from 'command-line-usage'
|
|
19
|
+
import Handlebars from 'handlebars'
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
debug,
|
|
23
|
+
log,
|
|
24
|
+
err,
|
|
25
|
+
errorExit,
|
|
26
|
+
shellCmd,
|
|
27
|
+
} from './Utils.mjs'
|
|
28
|
+
|
|
29
|
+
// Define CLI options
|
|
30
|
+
const optionList = [
|
|
31
|
+
{ name : 'sub-tag', type : String, description : '{green sub-tag to add to the image tag (required)}', defaultOption : true },
|
|
32
|
+
{ name : 'pg-version', type : String, description : '{green pgsql version (default: 16.6)}' },
|
|
33
|
+
{ name : 'version', type : Boolean, description : '{green show script version}' },
|
|
34
|
+
{ name : 'help', type : Boolean, description : '{green display this help screen}' },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const sections = [
|
|
38
|
+
{
|
|
39
|
+
header : 'Leverege CNPG Docker Image Builder',
|
|
40
|
+
content : `{green This tool will build a PostgreSQL based image that is suitable for
|
|
41
|
+
deployment by the CNPG operator. It builds the docker image by using an
|
|
42
|
+
official CNPG docker image as a base and added the jsquery and timescale
|
|
43
|
+
extensions for use within a Leverege k8s cluster. The resultant image may be
|
|
44
|
+
used in the standard PostgreSQL configuration which is used by the stack
|
|
45
|
+
components, as well as timescale based services like transponder tsdb and
|
|
46
|
+
dense history.}`
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
header : 'Options',
|
|
50
|
+
optionList
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
header : 'Leverege Registry Image Tag',
|
|
54
|
+
content : `{green The full registry image tag that is used for tagging the docker image in the artifact registry}`,
|
|
55
|
+
},
|
|
56
|
+
]
|
|
57
|
+
const args = cliArgs( optionList, { partial : true } )
|
|
58
|
+
const help = cliHelp( sections )
|
|
59
|
+
|
|
60
|
+
debug( { args, help }, '<==Command Line Info?' )
|
|
61
|
+
|
|
62
|
+
// Show help if needed
|
|
63
|
+
if ( args.help ) {
|
|
64
|
+
console.log( help )
|
|
65
|
+
process.exit( 0 )
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Define defaults
|
|
69
|
+
const PG_VERSION = args.pgVersion || '16.4'
|
|
70
|
+
const { subTag } = args
|
|
71
|
+
if ( !subTag ) {
|
|
72
|
+
errorExit( `Error: An image version must be specified.` )
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const LEVEREGE_REGISTRY = 'us-docker.pkg.dev/leverege-registry/system/images/leverege-pgsql'
|
|
76
|
+
const LEVEREGE_IMAGE_TAG = `${PG_VERSION}-cnpg-lvrg-${subTag}`
|
|
77
|
+
const LEVEREGE_IMAGE_NAME_WITH_TAG = `${LEVEREGE_REGISTRY}:${LEVEREGE_IMAGE_TAG}`
|
|
78
|
+
|
|
79
|
+
const DOCKERFILE_TEMPLATE = `
|
|
80
|
+
FROM ghcr.io/cloudnative-pg/postgresql:{{PG_VERSION}}-bookworm
|
|
81
|
+
|
|
82
|
+
USER root
|
|
83
|
+
|
|
84
|
+
RUN set -xe; \\
|
|
85
|
+
apt-get update; \\
|
|
86
|
+
apt-get install -y --no-install-recommends \\
|
|
87
|
+
"postgresql-\${PG_MAJOR}-jsquery"; \\
|
|
88
|
+
rm -fr /tmp/*; \\
|
|
89
|
+
rm -rf /var/lib/apt/lists/*;
|
|
90
|
+
|
|
91
|
+
RUN apt-get update \\
|
|
92
|
+
&& apt-get install -y lsb-release wget \\
|
|
93
|
+
&& echo "deb https://packagecloud.io/timescale/timescaledb/debian/ \$(lsb_release -c -s) main" | tee /etc/apt/sources.list.d/timescaledb.list \\
|
|
94
|
+
&& wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add - \\
|
|
95
|
+
&& apt-get update \\
|
|
96
|
+
&& apt-get install -y "timescaledb-2-postgresql-\${PG_MAJOR}" \\
|
|
97
|
+
&& apt-get remove -y lsb-release wget \\
|
|
98
|
+
&& rm -fr /tmp/* \\
|
|
99
|
+
&& rm -rf /var/lib/apt/lists/*;
|
|
100
|
+
|
|
101
|
+
RUN usermod -u 26 postgres
|
|
102
|
+
USER 26
|
|
103
|
+
`
|
|
104
|
+
|
|
105
|
+
// Check for existing image
|
|
106
|
+
const checkExistingImage = async ( imageName ) => {
|
|
107
|
+
const dockerResults= await shellCmd( `docker image list ${imageName} --quiet` )
|
|
108
|
+
debug( { imageName, dockerResults }, '<==docker image list' )
|
|
109
|
+
return dockerResults !== ''
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Build and push Docker image
|
|
113
|
+
const buildAndPushImage = async () => {
|
|
114
|
+
const template = Handlebars.compile( DOCKERFILE_TEMPLATE )
|
|
115
|
+
const renderedDockerfile = template( { PG_VERSION } )
|
|
116
|
+
debug( { renderedDockerfile }, '<==Dockerfile' )
|
|
117
|
+
|
|
118
|
+
// Write the Dockerfile to a temporary location
|
|
119
|
+
const dockerfilePath = path.resolve( 'Dockerfile.temp' )
|
|
120
|
+
fs.writeFileSync( dockerfilePath, renderedDockerfile )
|
|
121
|
+
|
|
122
|
+
// Build the image
|
|
123
|
+
console.log( chalk.yellow( 'Building Docker image...' ) )
|
|
124
|
+
await shellCmd( `docker build --file ${dockerfilePath} --tag ${LEVEREGE_IMAGE_NAME_WITH_TAG} .` )
|
|
125
|
+
|
|
126
|
+
// Push the image
|
|
127
|
+
console.log( chalk.green( 'Pushing Docker image...' ) )
|
|
128
|
+
await shellCmd( `docker push ${LEVEREGE_IMAGE_NAME_WITH_TAG}` )
|
|
129
|
+
|
|
130
|
+
// Clean up the temporary Dockerfile
|
|
131
|
+
fs.unlinkSync( dockerfilePath )
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Main execution flow
|
|
135
|
+
try {
|
|
136
|
+
if ( await checkExistingImage( LEVEREGE_IMAGE_NAME_WITH_TAG ) ) {
|
|
137
|
+
console.error(
|
|
138
|
+
`${chalk.red( '*** ERROR ***' )
|
|
139
|
+
} The image already exists:\n` +
|
|
140
|
+
` Image : ${chalk.yellow( LEVEREGE_IMAGE_NAME_WITH_TAG )}\n` +
|
|
141
|
+
` Registry: ${chalk.green( LEVEREGE_REGISTRY )}\n` +
|
|
142
|
+
` Tag : ${chalk.green( LEVEREGE_IMAGE_TAG )}\n`
|
|
143
|
+
)
|
|
144
|
+
process.exit( 1 )
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
console.log( `${chalk.cyan( 'About to build a new Docker image:\n' )
|
|
148
|
+
} PostgreSQL => ${chalk.green( PG_VERSION )}\n` +
|
|
149
|
+
` Image Name => ${chalk.green( LEVEREGE_IMAGE_NAME_WITH_TAG )}\n` )
|
|
150
|
+
|
|
151
|
+
console.log( `Enter "${chalk.green( 'yes' )}" to proceed or anything else to exit.` )
|
|
152
|
+
const confirmation = await new Promise( ( resolve ) => {
|
|
153
|
+
process.stdin.once( 'data', data => resolve( data.toString().trim() ) )
|
|
154
|
+
} )
|
|
155
|
+
|
|
156
|
+
if ( confirmation !== 'yes' ) {
|
|
157
|
+
console.log( chalk.red( 'Aborted by user.' ) )
|
|
158
|
+
process.exit( 1 )
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
await buildAndPushImage()
|
|
162
|
+
console.log( chalk.green( 'Docker image build and push completed successfully!' ) )
|
|
163
|
+
process.exit( 0 )
|
|
164
|
+
} catch ( error ) {
|
|
165
|
+
console.error( chalk.red( 'An error occurred:' ), error.message )
|
|
166
|
+
process.exit( 1 )
|
|
167
|
+
}
|
package/src/circleate.sh
CHANGED
|
@@ -128,7 +128,7 @@ jobs:
|
|
|
128
128
|
at: ~/project
|
|
129
129
|
- run:
|
|
130
130
|
name: Generate docs
|
|
131
|
-
command:
|
|
131
|
+
command: npm run docs
|
|
132
132
|
- store_artifacts:
|
|
133
133
|
path: docs
|
|
134
134
|
prefix: docs
|
|
@@ -347,7 +347,7 @@ jobs:
|
|
|
347
347
|
at: ~/project
|
|
348
348
|
- run:
|
|
349
349
|
name: Generate docs
|
|
350
|
-
command:
|
|
350
|
+
command: npm run docs
|
|
351
351
|
- store_artifacts:
|
|
352
352
|
path: docs
|
|
353
353
|
prefix: docs
|
|
@@ -96,8 +96,6 @@ if ( semver.lt( semver.coerce( repoDescr.buildToolsVersion ), minimumBuildToolsV
|
|
|
96
96
|
|
|
97
97
|
const dockerInfo = await docker.generateDockerfile( {
|
|
98
98
|
regvers : repoDescr.packageVersion,
|
|
99
|
-
imageBase : repoDescr.closestPackageJson.leverege?.imageBase,
|
|
100
|
-
buildEnv : repoDescr.closestPackageJson.leverege?.buildEnv || 'alpine',
|
|
101
99
|
nodeimage : repoDescr.closestPackageJson.leverege?.nodeimg, // left as nodeimg in package.json for backwards compat
|
|
102
100
|
} )
|
|
103
101
|
debug( { dockerInfo }, '<==The Docker Info' )
|
|
@@ -218,13 +216,13 @@ log( `
|
|
|
218
216
|
NPM Workspace: ${chalk.green.bold( isNpmWorkspace )}
|
|
219
217
|
|
|
220
218
|
${chalk.green.bold( 'Docker Information:' )}
|
|
221
|
-
NodeImage: ${chalk.green.bold( dockerInfo.
|
|
222
|
-
Docker Env: ${chalk.green.bold( dockerInfo.buildEnv || 'alpine' )}
|
|
219
|
+
NodeImage: ${chalk.green.bold( dockerInfo.nodeimage )}
|
|
223
220
|
AddedPkgs: ${chalk.green.bold( dockerInfo.apkadds )}
|
|
224
221
|
Run User: ${chalk.green.bold( dockerInfo.runuser )}
|
|
225
222
|
Previous: ${chalk.yellow.bold( dockerInfo.previousBuild )}
|
|
226
223
|
DateStamp: ${chalk.green.bold( dockerInfo.date )}
|
|
227
224
|
NPM Logs: ${chalk.green.bold( dockerInfo.npmlogging )}
|
|
225
|
+
NPM Version: ${chalk.green.bold( dockerInfo.npmVersion )}
|
|
228
226
|
` )
|
|
229
227
|
|
|
230
228
|
if ( imageVersion !== packageVersion ) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tags": {
|
|
3
|
+
"allowUnknownTags": false
|
|
4
|
+
},
|
|
5
|
+
"source": {
|
|
6
|
+
"includePattern": "\\.(js|mjs|jsx)$",
|
|
7
|
+
"excludePattern": "(node_modules/|docs)"
|
|
8
|
+
},
|
|
9
|
+
"plugins": [],
|
|
10
|
+
"templates": {
|
|
11
|
+
"cleverLinks": true,
|
|
12
|
+
"monospaceLinks": false,
|
|
13
|
+
"preserveDescriptions": true,
|
|
14
|
+
"default": {
|
|
15
|
+
"useLongnameInNav": true,
|
|
16
|
+
"outputSourceFiles": false
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"opts": {
|
|
20
|
+
"encoding": "utf8",
|
|
21
|
+
"lenient": false,
|
|
22
|
+
"markdown": true
|
|
23
|
+
},
|
|
24
|
+
"docdash": {
|
|
25
|
+
"static": true,
|
|
26
|
+
"sort": false,
|
|
27
|
+
"search": true,
|
|
28
|
+
"collapse": true,
|
|
29
|
+
"typedefs": true,
|
|
30
|
+
"removeQuotes": "none",
|
|
31
|
+
"scripts": [],
|
|
32
|
+
"menu":{
|
|
33
|
+
"Bitbucket": {
|
|
34
|
+
"href":"https://bitbucket.org/leverege/IF_THIS_MAKES_SENSE",
|
|
35
|
+
"target":"_blank",
|
|
36
|
+
"class":"menu-item",
|
|
37
|
+
"id":"repository"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Encapsulates the rather lengthy jsdoc / md docs npm script:
|
|
4
|
+
*
|
|
5
|
+
* npx jsdoc -c ./jsdoc.json -R README.md -d docs src && \
|
|
6
|
+
* mkdir -p docs/md && \
|
|
7
|
+
* npx --package=jsdoc-to-markdown jsdoc2md --files src/*.js --configure ./jsdoc.json > docs/md/API.md
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
BUILD_TOOLS_ROOT,
|
|
14
|
+
debug,
|
|
15
|
+
err,
|
|
16
|
+
getRepositoryDescr,
|
|
17
|
+
shellCmd,
|
|
18
|
+
} from './Utils.mjs'
|
|
19
|
+
|
|
20
|
+
const jsdocConfig = `${BUILD_TOOLS_ROOT}/generate-docs-conf.json`
|
|
21
|
+
|
|
22
|
+
// build the location of the template file from the build-tools root
|
|
23
|
+
// in order to avoid hardcoding in the jsdoc config file - this is
|
|
24
|
+
// important in order to support running generate-docs from a user's
|
|
25
|
+
// laptop or deployed to the doc-creator service on k8s
|
|
26
|
+
const jsdocTemplate = `${BUILD_TOOLS_ROOT}/../../jsdoc-template`
|
|
27
|
+
|
|
28
|
+
if ( !fs.existsSync( jsdocConfig ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
|
|
29
|
+
err( `cannot find the jsdoc config file: ${jsdocConfig}` )
|
|
30
|
+
process.exit( 1 )
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const repoDescr = await getRepositoryDescr()
|
|
34
|
+
|
|
35
|
+
debug( { jsdocConfig, repoDescr }, '<==The Repo' )
|
|
36
|
+
|
|
37
|
+
// blow away any existing docs before recreating the docs dir
|
|
38
|
+
if ( fs.existsSync( 'docs' ) ) {
|
|
39
|
+
fs.rmSync( 'docs', { recursive : true } )
|
|
40
|
+
}
|
|
41
|
+
fs.mkdirSync( 'docs/md', { recursive : true } )
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await shellCmd( `npx --yes jsdoc -c ${jsdocConfig} -t ${jsdocTemplate} -R README.md -d docs src` )
|
|
45
|
+
await shellCmd(
|
|
46
|
+
`npx --yes --package=jsdoc-to-markdown jsdoc2md --files src/*.js --configure ${jsdocConfig}`,
|
|
47
|
+
{ stdout : { file : 'docs/md/API.md' } }
|
|
48
|
+
)
|
|
49
|
+
} catch ( error ) {
|
|
50
|
+
err( error )
|
|
51
|
+
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
#
|
|
3
3
|
# See => https://cloudnative-pg.io/documentation/current/installation_upgrade/
|
|
4
4
|
#
|
|
5
|
+
OPVER="1.25.0"
|
|
6
|
+
|
|
7
|
+
createNamespaceIfNeeded cnpg-system
|
|
8
|
+
|
|
9
|
+
kubectl apply --server-side -f \
|
|
10
|
+
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-${OPVER%.*}/releases/cnpg-${OPVER}.yaml $K8S_WHAT
|
|
11
|
+
|
|
5
12
|
# Legacy terraformed clusters (like sandbox) may need a special firewall rule
|
|
6
13
|
# added to the network layer on k8s. It should look like this:
|
|
7
14
|
#
|
|
@@ -9,13 +16,6 @@
|
|
|
9
16
|
# Ports : 8000,9443 <= kubectl cnpg status and webhooks
|
|
10
17
|
# Filters: 172.16.0.0/28 <= k8s control plane
|
|
11
18
|
#
|
|
12
|
-
OPVER="1.24.1"
|
|
13
|
-
|
|
14
|
-
createNamespaceIfNeeded cnpg-system
|
|
15
|
-
|
|
16
|
-
kubectl apply --server-side -f \
|
|
17
|
-
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-${OPVER%.*}/releases/cnpg-${OPVER}.yaml $K8S_WHAT
|
|
18
|
-
|
|
19
19
|
# Old approach used the helm chart.
|
|
20
20
|
#
|
|
21
21
|
#addHelmRepo cnpg https://cloudnative-pg.github.io/charts
|
|
@@ -4,7 +4,7 @@ showInstalling "The Prometheus Operator and Components"
|
|
|
4
4
|
addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
|
|
5
5
|
|
|
6
6
|
showInstalling "The Prometheus Operator (kube-prometheus-stack)"
|
|
7
|
-
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="
|
|
7
|
+
[ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="67"
|
|
8
8
|
|
|
9
9
|
NS="--namespace prometheus"
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ showInstalling "Redis"
|
|
|
4
4
|
|
|
5
5
|
OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
|
|
6
6
|
|
|
7
|
-
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.
|
|
7
|
+
[ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.6.1"
|
|
8
8
|
|
|
9
9
|
helm upgrade --install redis $OCI_CHART \
|
|
10
10
|
--values redis/redis-local.yaml \
|
|
@@ -4,7 +4,7 @@ showInstalling "Velero Backup System"
|
|
|
4
4
|
|
|
5
5
|
addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
|
|
6
6
|
|
|
7
|
-
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="
|
|
7
|
+
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="8"
|
|
8
8
|
#
|
|
9
9
|
# Build the bucket, region and SA email variables and use --set to mod the
|
|
10
10
|
# chart values as opposed to using an OVH:<label> approach. This eliminates
|
|
@@ -129,6 +129,10 @@ serviceAccount:
|
|
|
129
129
|
create: false
|
|
130
130
|
name: velero
|
|
131
131
|
|
|
132
|
+
metrics:
|
|
133
|
+
serviceMonitor:
|
|
134
|
+
enabled: true
|
|
135
|
+
|
|
132
136
|
# Workload Identity Federation (WIF) uses service accounts and IAM roles to
|
|
133
137
|
# define a service's permissions - the useSecret setting will be set to false
|
|
134
138
|
# for WIF enabled clusters.
|