@leverege/build-tools 2.6.5 → 2.6.7
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/lib/server/repo-init/config.tgz +0 -0
- package/lib/server/repo-init/templates/ToBuildSpec.js +60 -65
- package/package.json +9 -9
- package/src/dockreate +14 -6
- package/src/helmup +18 -4
|
Binary file
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
|
|
5
3
|
const {
|
|
6
4
|
Transform
|
|
7
5
|
} = require('stream');
|
|
@@ -17,79 +15,76 @@ class ToBuildSpec extends Transform {
|
|
|
17
15
|
super({
|
|
18
16
|
objectMode: true
|
|
19
17
|
});
|
|
18
|
+
this.buildSpec = buildSpec;
|
|
19
|
+
this.regexp = new RegExp('REPI:<(\\w+\\.*\\w*)>', 'g');
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
_transform = function _transformFunc(chunk, encoding, done) {
|
|
23
|
+
const chunkStr = chunk.toString();
|
|
24
|
+
/**
|
|
25
|
+
* Concern of possible partial strings when working with large files.
|
|
26
|
+
* In this case, most source will be less than 10K so this should not
|
|
27
|
+
* be a problem for the most part, but error out if it occurs.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
if (!chunkStr.endsWith('\n')) {
|
|
31
|
+
// TODO: This logic if flawed looking for \n
|
|
32
|
+
console.error(`***PARTIAL LINE***[${chunkStr}]`);
|
|
33
|
+
process.exit(1); // TODO: throw something not exit
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Used for pulling nested or flat values from the buildSpec. This allows
|
|
37
|
+
* the build spec to look like this:
|
|
38
|
+
* {
|
|
39
|
+
* gitName : 'myName',
|
|
40
|
+
* git : {
|
|
41
|
+
* name : 'myName',
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* and either can be retrieved with a key of gitName or git.name.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const valueFromSpec = (key, spec = this.buildSpec) => {
|
|
49
|
+
if (!key.match(/\.+/)) {
|
|
50
|
+
return spec[key];
|
|
33
51
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Used for pulling nested or flat values from the buildSpec. This allows
|
|
36
|
-
* the build spec to look like this:
|
|
37
|
-
* {
|
|
38
|
-
* gitName : 'myName',
|
|
39
|
-
* git : {
|
|
40
|
-
* name : 'myName',
|
|
41
|
-
* }
|
|
42
|
-
* }
|
|
43
|
-
* and either can be retrieved with a key of gitName or git.name.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const valueFromSpec = (key, spec = this.buildSpec) => {
|
|
48
|
-
if (!key.match(/\.+/)) {
|
|
49
|
-
return spec[key];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const keys = key.split('.');
|
|
53
|
-
return valueFromSpec(keys[1], spec[keys[0]]);
|
|
54
|
-
};
|
|
55
52
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const keys = key.split('.');
|
|
54
|
+
return valueFromSpec(keys[1], spec[keys[0]]);
|
|
55
|
+
};
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const splitLines = chunkStr.split('\n');
|
|
58
|
+
const xfmLines = splitLines.map(line => {
|
|
59
|
+
let replaced = line;
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
61
|
+
for (const match of line.matchAll(this.regexp)) {
|
|
62
|
+
// eslint-disable-line no-restricted-syntax
|
|
63
|
+
const replaceWith = valueFromSpec(match[1]);
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
if (typeof replaceWith === 'undefined') {
|
|
66
|
+
// console.log( `Skipping unknown build spec property =>[${match[1]}]` )//XXX
|
|
67
|
+
continue;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
const xfmString = xfmLines.join('\n');
|
|
75
|
-
this.push(Buffer.from(xfmString));
|
|
76
|
-
done();
|
|
77
|
-
});
|
|
70
|
+
replaced = replaced.replace(match[0], replaceWith);
|
|
71
|
+
}
|
|
78
72
|
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
if ( this._partialLine ) {
|
|
82
|
-
this.push( [ this._partialLine ] )
|
|
83
|
-
}
|
|
84
|
-
this._partialLine = null
|
|
85
|
-
*/
|
|
86
|
-
done();
|
|
73
|
+
return replaced;
|
|
87
74
|
});
|
|
88
|
-
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
75
|
+
const xfmString = xfmLines.join('\n');
|
|
76
|
+
this.push(Buffer.from(xfmString));
|
|
77
|
+
done();
|
|
78
|
+
};
|
|
79
|
+
_flush = function _flushFunc(done) {
|
|
80
|
+
/**
|
|
81
|
+
if ( this._partialLine ) {
|
|
82
|
+
this.push( [ this._partialLine ] )
|
|
83
|
+
}
|
|
84
|
+
this._partialLine = null
|
|
85
|
+
*/
|
|
86
|
+
done();
|
|
87
|
+
};
|
|
93
88
|
}
|
|
94
89
|
|
|
95
90
|
module.exports = ToBuildSpec;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -64,21 +64,21 @@
|
|
|
64
64
|
"inquirer": "^8.1.2",
|
|
65
65
|
"js-yaml": "^4.1.0",
|
|
66
66
|
"ncp": "^2.0.0",
|
|
67
|
-
"npm-check-updates": "^11.8.
|
|
67
|
+
"npm-check-updates": "^11.8.5",
|
|
68
68
|
"npm-registry-fetch": "^11.0.0",
|
|
69
69
|
"open": "^8.2.1",
|
|
70
70
|
"ora": "^5.4.1",
|
|
71
71
|
"parse-gitignore": "^1.0.1",
|
|
72
72
|
"readline-sync": "^1.4.10",
|
|
73
73
|
"semver": "^7.3.5",
|
|
74
|
-
"simple-git": "^2.
|
|
74
|
+
"simple-git": "^2.45.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@babel/cli": "^7.
|
|
78
|
-
"@babel/core": "^7.15.
|
|
79
|
-
"@babel/node": "^7.
|
|
80
|
-
"@leverege/babel-preset-leverege-node": "^
|
|
81
|
-
"@leverege/eslint-config-leverege": "^3.0.
|
|
82
|
-
"npm": "^7.
|
|
77
|
+
"@babel/cli": "^7.15.4",
|
|
78
|
+
"@babel/core": "^7.15.5",
|
|
79
|
+
"@babel/node": "^7.15.4",
|
|
80
|
+
"@leverege/babel-preset-leverege-node": "^2.0.0",
|
|
81
|
+
"@leverege/eslint-config-leverege": "^3.0.1",
|
|
82
|
+
"npm": "^7.22.0"
|
|
83
83
|
}
|
|
84
84
|
}
|
package/src/dockreate
CHANGED
|
@@ -52,6 +52,7 @@ create_Dockerfile() {
|
|
|
52
52
|
local regvers="${1}"
|
|
53
53
|
local nodeimg="${2:-fermium-alpine}"
|
|
54
54
|
local apkadds="${3}"
|
|
55
|
+
|
|
55
56
|
echo "Creating the Dockerfile for node ${nodeimg}"
|
|
56
57
|
cat<<DOCKERBLD > Dockerfile
|
|
57
58
|
# Version ${regvers} @ `date`
|
|
@@ -73,10 +74,11 @@ ENV GRPC_VERBOSITY ERROR
|
|
|
73
74
|
|
|
74
75
|
# Install packages to install private repos with ssh keys
|
|
75
76
|
COPY ./.npmrc /usr/src/app/.npmrc
|
|
76
|
-
RUN apk --no-cache add
|
|
77
|
+
RUN apk --no-cache add openssh-client && \
|
|
77
78
|
apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
|
|
78
79
|
libstdc++ linux-headers make python ${apkadds} && \
|
|
79
|
-
npm
|
|
80
|
+
npm install -g npm@7 && \
|
|
81
|
+
npm ci --only-production --ignore-scripts ${npmlogging} && \
|
|
80
82
|
rm -f /usr/src/app/.npmrc /root/.ssh/*
|
|
81
83
|
|
|
82
84
|
# --------------------------------------------------------------
|
|
@@ -87,9 +89,11 @@ FROM node:${nodeimg}
|
|
|
87
89
|
|
|
88
90
|
# Install tini for PID 1 and replace shell with bash so we can source files
|
|
89
91
|
RUN apk update && \
|
|
90
|
-
apk add --no-cache tini
|
|
92
|
+
apk add --no-cache bash curl tini vim ${apkadds} && \
|
|
93
|
+
npm install -g npm@7 && \
|
|
91
94
|
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
92
|
-
mkdir -p /usr/src/app /tmp/levlog
|
|
95
|
+
mkdir -p /usr/src/app /tmp/levlog && \
|
|
96
|
+
chown node:node /usr/src/app
|
|
93
97
|
DOCKERBLD
|
|
94
98
|
|
|
95
99
|
if [ -f "${pluginFile}" ];
|
|
@@ -195,6 +199,9 @@ apkadds=$(strip_undefined "`node -p \"require('../package.json').leverege.apkadd
|
|
|
195
199
|
runuser=$(strip_undefined "`node -p \"require('../package.json').leverege.runuser\"`")
|
|
196
200
|
[ -z "${runuser}" ] && runuser='node'
|
|
197
201
|
|
|
202
|
+
npmlogging='--silent' # allow for verbose npm logs
|
|
203
|
+
[ "$VERBOSE_DOCKREATE_NPM" == "yes" ] && npmlogging='--ddd'
|
|
204
|
+
|
|
198
205
|
echo "Updating dependencies and workspace..." && npm install
|
|
199
206
|
|
|
200
207
|
container="`node -p \"require('../package.json').leverege.container\"`"
|
|
@@ -286,6 +293,7 @@ cat<<IMGINFO
|
|
|
286
293
|
Project: $(colorize 'green' "$project")
|
|
287
294
|
Container: $(colorize 'green' "$container")
|
|
288
295
|
NodeImage: $(colorize 'green' "$nodeimg")
|
|
296
|
+
NPM Logs: $(colorize 'green' "$npmlogging")
|
|
289
297
|
AddedPkgs: $(colorize 'green' "$apkadds")
|
|
290
298
|
PluggedIn: ${pluggedIn}
|
|
291
299
|
Version: $(colorize 'green' "$version") $tagstat
|
|
@@ -363,14 +371,14 @@ BUILDERR
|
|
|
363
371
|
fi
|
|
364
372
|
|
|
365
373
|
# Tag the container with the node detailsand the culprit.
|
|
366
|
-
gcloud
|
|
374
|
+
gcloud container images add-tag --quiet $gcimage:$version $gcimage:$pckgdts-$nodeimg-$USER
|
|
367
375
|
|
|
368
376
|
if [ $tagging ];
|
|
369
377
|
then
|
|
370
378
|
printf "\n$(colorize 'green' "Tagging and Pushing $version")\n"
|
|
371
379
|
git tag -af $1 -m "Docker version $1"
|
|
372
380
|
git push --follow-tags
|
|
373
|
-
gcloud
|
|
381
|
+
gcloud container images add-tag --quiet $gcimage:$version $gcimage:latest
|
|
374
382
|
else
|
|
375
383
|
printf "\n$(colorize 'yellow' '*** Skipped git tagging - beta release')\n\n"
|
|
376
384
|
fi
|
package/src/helmup
CHANGED
|
@@ -31,6 +31,7 @@ SYSTEM=(
|
|
|
31
31
|
postgres
|
|
32
32
|
timescale-db
|
|
33
33
|
monitoring
|
|
34
|
+
preemptible-killer
|
|
34
35
|
reloader
|
|
35
36
|
traefik
|
|
36
37
|
velero
|
|
@@ -137,7 +138,7 @@ SA_EXISTS
|
|
|
137
138
|
printf "\n*** Binding IAM role of monitoring viewer to stackdriver-exporter in $GCP_PROJECT_ID\n"
|
|
138
139
|
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
139
140
|
--role "roles/monitoring.viewer" \
|
|
140
|
-
--member "serviceAccount:$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
141
|
+
--member "serviceAccount:$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" &>/dev/null
|
|
141
142
|
|
|
142
143
|
printf "\n*** Binding IAM role of workloadIdentityUser to stackdriver-exporter\n"
|
|
143
144
|
gcloud iam service-accounts add-iam-policy-binding \
|
|
@@ -157,20 +158,21 @@ SA_EXISTS
|
|
|
157
158
|
helm upgrade --install prometheus prometheus-community/prometheus \
|
|
158
159
|
--namespace monitoring \
|
|
159
160
|
--values prometheus/values.yaml \
|
|
160
|
-
--version 13
|
|
161
|
+
--version 13
|
|
161
162
|
|
|
162
163
|
## Installing ES exporter
|
|
163
164
|
helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
|
|
164
165
|
--namespace monitoring \
|
|
165
166
|
--values elasticsearch-exporter/values-es-exporter.yaml \
|
|
166
|
-
--version 4.
|
|
167
|
+
--version 4.6
|
|
167
168
|
|
|
168
169
|
## Install Grafana
|
|
169
170
|
helm repo add grafana https://grafana.github.io/helm-charts && helm repo update
|
|
170
171
|
helm upgrade --install grafana grafana/grafana \
|
|
171
172
|
--namespace monitoring \
|
|
172
173
|
--values grafana/values-grafana.yaml \
|
|
173
|
-
--version 6.
|
|
174
|
+
--version 6.11 # 6.11 last of v7 grafana
|
|
175
|
+
# --version 6.16 # latest v8 grafana
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
function monitoringHelp(){
|
|
@@ -235,6 +237,14 @@ function getManagedSecret() {
|
|
|
235
237
|
echo $SECRET
|
|
236
238
|
}
|
|
237
239
|
|
|
240
|
+
# https://github.com/estafette/estafette-gke-preemptible-killer
|
|
241
|
+
function installPreemptibleKiller() {
|
|
242
|
+
helm repo add estafette https://helm.estafette.io &>/dev/null
|
|
243
|
+
helm upgrade --install estafette-gke-preemptible-killer \
|
|
244
|
+
estafette/estafette-gke-preemptible-killer --namespace estafette
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
238
248
|
function installTraefik() {
|
|
239
249
|
createNamespaceIfNeeded traefik
|
|
240
250
|
|
|
@@ -497,6 +507,10 @@ function doInstall() {
|
|
|
497
507
|
helm upgrade --install postgres bitnami/postgresql -f postgres/postgres-values.yaml --version 8.9.6
|
|
498
508
|
;;
|
|
499
509
|
|
|
510
|
+
"preemptible-killer")
|
|
511
|
+
installPreemptibleKiller # the gke preemptible node spreader outer
|
|
512
|
+
;;
|
|
513
|
+
|
|
500
514
|
"redis")
|
|
501
515
|
# https://github.com/helm/charts/tree/master/stable/redis
|
|
502
516
|
[ -z "$REDIS_HELM_CHART" ] && REDIS_HELM_CHART="v9.1.5"
|