@leverege/build-tools 2.48.5 → 2.49.0
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 +6 -5
- package/registry-compass.yaml +20 -0
- package/src/chart-compass.mjs +96 -0
- package/src/cnpg-snapshot.mjs +4 -29
- package/src/docker-to-registry.sh +611 -0
- package/src/helm-charts/api-server/values-local.yaml +7 -0
- package/src/helm-charts/authz-server/values-local.yaml +3 -0
- package/src/helm-charts/cnpg-db-pgbench/cnpg-db-pgbench.yaml.ovh +100 -0
- package/src/helm-charts/cnpg-db-pgbench/gitignore +2 -0
- package/src/helm-charts/cnpg-db-pgbench/helmdn.plugin +12 -0
- package/src/helm-charts/cnpg-db-pgbench/helmup.plugin +3 -0
- package/src/helm-charts/cnpg-db-pgbench/pooler.yaml +16 -0
- package/src/helm-charts/{db-postgres-stack/db-postgres-stack.yaml.ovh → cnpg-db-psql-stack/cnpg-db-psql-stack.yaml.ovh} +6 -24
- package/src/helm-charts/cnpg-db-psql-stack/gitignore +2 -0
- package/src/helm-charts/cnpg-db-psql-stack/helmdn.plugin +12 -0
- package/src/helm-charts/cnpg-db-psql-stack/helmup.plugin +3 -0
- package/src/helm-charts/cnpg-db-psql-stack/pooler.yaml +16 -0
- package/src/helm-charts/{db-timescale-plain/db-timescale-plain.yaml.ovh → cnpg-db-tsdb-basic/cnpg-db-tsdb-basic.yaml.ovh} +8 -28
- package/src/helm-charts/cnpg-db-tsdb-basic/gitignore +2 -0
- package/src/helm-charts/cnpg-db-tsdb-basic/helmdn.plugin +12 -0
- package/src/helm-charts/cnpg-db-tsdb-basic/helmup.plugin +3 -0
- package/src/helm-charts/cnpg-db-tsdb-basic/pooler.yaml +16 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/.nohelm +0 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/.nohelmdn +0 -0
- package/src/helm-charts/{db-timescale-dense/db-timescale-dense.yaml.ovh → cnpg-db-tsdb-dense/cnpg-db-tsdb-dense.yaml.ovh} +7 -27
- package/src/helm-charts/cnpg-db-tsdb-dense/gitignore +2 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/helmdn.plugin +12 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/helmup.plugin +5 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/pooler.yaml +16 -0
- package/src/helm-charts/cnpg-operator/helmup.plugin +1 -1
- package/src/helm-charts/elasticsearch8/helmup.plugin +4 -5
- package/src/helm-charts/fota-server/values-local.yaml +3 -0
- package/src/helm-charts/kube-prometheus-stack/helmup.plugin +13 -0
- package/src/helm-charts/kube-prometheus-stack/old-values-local.yaml +764 -0
- package/src/helm-charts/pusher/values-local.yaml +2 -2
- package/src/helm-charts/resource-server/values-local.yaml +3 -0
- package/src/helm-charts/rule-engine/values-local.yaml +3 -0
- package/src/helm-charts/scheduler/values-local.yaml +3 -0
- package/src/helm-charts/transponder-tsdb/values-local.yaml +3 -0
- package/src/helm-charts/velero/helmup.plugin +1 -1
- package/src/helm-charts/velero/velero-local.yaml +1 -1
- package/src/helmup.sh +15 -26
- package/src/helm-charts/db-postgres-stack/gitignore +0 -1
- package/src/helm-charts/db-postgres-stack/helmdn.plugin +0 -3
- package/src/helm-charts/db-postgres-stack/helmup.plugin +0 -3
- package/src/helm-charts/db-timescale-dense/gitignore +0 -1
- package/src/helm-charts/db-timescale-dense/helmdn.plugin +0 -9
- package/src/helm-charts/db-timescale-dense/helmup.plugin +0 -5
- package/src/helm-charts/db-timescale-plain/gitignore +0 -1
- package/src/helm-charts/db-timescale-plain/helmdn.plugin +0 -3
- package/src/helm-charts/db-timescale-plain/helmup.plugin +0 -3
- /package/src/helm-charts/{db-postgres-stack → cnpg-db-pgbench}/.nohelm +0 -0
- /package/src/helm-charts/{db-postgres-stack → cnpg-db-pgbench}/.nohelmdn +0 -0
- /package/src/helm-charts/{db-timescale-dense → cnpg-db-psql-stack}/.nohelm +0 -0
- /package/src/helm-charts/{db-timescale-dense → cnpg-db-psql-stack}/.nohelmdn +0 -0
- /package/src/helm-charts/{db-timescale-plain → cnpg-db-tsdb-basic}/.nohelm +0 -0
- /package/src/helm-charts/{db-timescale-plain → cnpg-db-tsdb-basic}/.nohelmdn +0 -0
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
if [ -z "$1" ]; then
|
|
3
|
+
echo " Usage: docker-to-registry <version number>"
|
|
4
|
+
exit 1
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
# printf "\n****LOCAL DOCKREATE****\n\n" && sleep 1
|
|
8
|
+
|
|
9
|
+
# The base docker image maybe overridden with:
|
|
10
|
+
#
|
|
11
|
+
# BASE_NODE_IMAGE="gallium-alpine" npm run dockerize <version>
|
|
12
|
+
#
|
|
13
|
+
BASE_NODE_IMAGE="${BASE_NODE_IMAGE:-iron-alpine}" # node 20, iron
|
|
14
|
+
|
|
15
|
+
# Load common bash functions
|
|
16
|
+
. `build-tools --bashfun`
|
|
17
|
+
cat<<DEPRECATED_TOOL
|
|
18
|
+
|
|
19
|
+
`color y "***DEPRECATED docker-to-registry.sh - upgrade to docker-to-registry.mjs***"`
|
|
20
|
+
|
|
21
|
+
DEPRECATED_TOOL
|
|
22
|
+
sleep 3
|
|
23
|
+
|
|
24
|
+
PKGTOP="$npm_config_local_prefix"
|
|
25
|
+
cd $PKGTOP/docker
|
|
26
|
+
|
|
27
|
+
if [ ! -x "$(command -v jq)" ];
|
|
28
|
+
then
|
|
29
|
+
cat<<NO_JQ
|
|
30
|
+
|
|
31
|
+
`color r "***ERROR: Missing jq JSON processor"` => `color g 'brew install jq'`
|
|
32
|
+
|
|
33
|
+
NO_JQ
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
if [ ! -d "$PKGTOP/dist" ];
|
|
38
|
+
then
|
|
39
|
+
cat<<NO_DIST
|
|
40
|
+
|
|
41
|
+
`color r "***ERROR: Missing the dist directory, run this first => "``color g 'npm run build'`
|
|
42
|
+
|
|
43
|
+
NO_DIST
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
function packageJson() {
|
|
48
|
+
result=$(jq -r $1 $PKGTOP/package.json)
|
|
49
|
+
if [ "$result" != "null" ]
|
|
50
|
+
then
|
|
51
|
+
echo $result
|
|
52
|
+
else
|
|
53
|
+
echo $2
|
|
54
|
+
fi
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Global Vars
|
|
58
|
+
pluginFile="Dockerfile.plugin"
|
|
59
|
+
|
|
60
|
+
# cleanup trapper for gracefully killing, which doesn't do much right now
|
|
61
|
+
function cleanup() {
|
|
62
|
+
[ ! -z "$DOCKER_SKIP_CLEANUP" ] && printf "\nSkipping clean up\n\n" && exit 1
|
|
63
|
+
printf "\nCleaning up and exiting...\n\n"
|
|
64
|
+
rm -rf ./workspace ./scripts $SSHDIR .npmrc
|
|
65
|
+
exit 0
|
|
66
|
+
}
|
|
67
|
+
trap cleanup INT
|
|
68
|
+
|
|
69
|
+
function strip_undefined() {
|
|
70
|
+
local result="$1"
|
|
71
|
+
[ "$1" == "undefined" ] && result=""
|
|
72
|
+
printf "$result"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function create_DockerfilePlugin() {
|
|
76
|
+
[ -f 'Dockerfile.plugin' ] && return
|
|
77
|
+
|
|
78
|
+
cat<<DOCKERPLUGIN > Dockerfile.plugin
|
|
79
|
+
# Dockerfile.plugin - optionally extend the service Docker image
|
|
80
|
+
#
|
|
81
|
+
# This file may be used to run additional docker commands during the image
|
|
82
|
+
# build process without needing to maintain a local custom Dockerfile. For
|
|
83
|
+
# example, uncommenting the following docker RUN command will cause the
|
|
84
|
+
# curl and vim packages to be added to the deployed image thus making them
|
|
85
|
+
# available from the pod's command line on k8s:
|
|
86
|
+
#
|
|
87
|
+
# RUN apk update && apk add --no-cache curl vim
|
|
88
|
+
#
|
|
89
|
+
# Keep in mind that the Alpine Linux base image is used to keep image
|
|
90
|
+
# footprints small, so adding packages "just because" is not considered
|
|
91
|
+
# a best practice.
|
|
92
|
+
DOCKERPLUGIN
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Useful links with information regarding k8s/docker/nodejs and PID 1
|
|
96
|
+
# No PID 1 for NodeJS => https://bit.ly/2r4gHkZ
|
|
97
|
+
# What tini is all about => https://bit.ly/2HsSxqP
|
|
98
|
+
# Graceful kills with k8s => https://bit.ly/2NONEJG
|
|
99
|
+
#
|
|
100
|
+
# Params: $1 = version from dockerize invocation
|
|
101
|
+
# $2 = additional packages to install (htop redis-cli etc)
|
|
102
|
+
function create_Dockerfile() {
|
|
103
|
+
local regvers="${1}"
|
|
104
|
+
local apkadds="${2}"
|
|
105
|
+
|
|
106
|
+
create_DockerfilePlugin
|
|
107
|
+
|
|
108
|
+
echo "Creating the Dockerfile for node ${BASE_NODE_IMAGE}"
|
|
109
|
+
cat<<DOCKERBLD > Dockerfile
|
|
110
|
+
# Version ${regvers} @ `date`
|
|
111
|
+
#
|
|
112
|
+
# The FROM directive sets the Base Image for subsequent instructions
|
|
113
|
+
FROM node:${BASE_NODE_IMAGE} as intermediate
|
|
114
|
+
ENV NODE_ENV production
|
|
115
|
+
|
|
116
|
+
RUN mkdir -p /usr/src/app
|
|
117
|
+
WORKDIR /usr/src/app
|
|
118
|
+
|
|
119
|
+
# Install app dependencies
|
|
120
|
+
COPY ./workspace/ /usr/src/app/
|
|
121
|
+
ENV GRPC_VERBOSITY ERROR
|
|
122
|
+
|
|
123
|
+
# --------------------------------------------------------------
|
|
124
|
+
# copy the ssh keys into place, npm install, and remove them
|
|
125
|
+
# --------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
# Install packages to install private repos with ssh keys
|
|
128
|
+
COPY ./.npmrc /usr/src/app/.npmrc
|
|
129
|
+
RUN apk --no-cache add openssh-client && \
|
|
130
|
+
apk --update add --no-cache --virtual build-dep g++ gcc libgcc \\
|
|
131
|
+
libstdc++ linux-headers make ${apkadds} && \
|
|
132
|
+
npm install -g npm@10 && \
|
|
133
|
+
npm ci --only=production --ignore-scripts --no-optional ${npmlogging} && \
|
|
134
|
+
rm -f /usr/src/app/.npmrc /root/.ssh/*
|
|
135
|
+
|
|
136
|
+
# --------------------------------------------------------------
|
|
137
|
+
# On to the real build now, the thing before was just an intermediate container
|
|
138
|
+
# --------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
FROM node:${BASE_NODE_IMAGE}
|
|
141
|
+
|
|
142
|
+
# Install tini for PID 1 and replace shell with bash so we can source files
|
|
143
|
+
RUN apk update && \
|
|
144
|
+
apk add --no-cache bash curl tini vim ${apkadds} && \
|
|
145
|
+
npm install -g npm@10 && \
|
|
146
|
+
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
147
|
+
mkdir -p /usr/src/app /tmp/levlog && \
|
|
148
|
+
chown node:node /usr/src/app
|
|
149
|
+
DOCKERBLD
|
|
150
|
+
|
|
151
|
+
if [ -f "${pluginFile}" ];
|
|
152
|
+
then
|
|
153
|
+
printf "\n# ${pluginFile} BEGIN\n" >> Dockerfile
|
|
154
|
+
cat $pluginFile >> Dockerfile
|
|
155
|
+
printf "# ${pluginFile} END\n\n" >> Dockerfile
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
cat<<EODOCKER >> Dockerfile
|
|
159
|
+
ENTRYPOINT [ "/sbin/tini", "--" ]
|
|
160
|
+
WORKDIR /usr/src/app
|
|
161
|
+
|
|
162
|
+
COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
|
|
163
|
+
|
|
164
|
+
USER ${runuser}
|
|
165
|
+
COPY ./bashrc /home/node/.bashrc
|
|
166
|
+
CMD [ "/bin/bash", "-c", "node index.js" ]
|
|
167
|
+
EODOCKER
|
|
168
|
+
} # end of create_Dockerfile
|
|
169
|
+
|
|
170
|
+
# Params: $1 = version from dockerize invocation
|
|
171
|
+
function create_bashrc() {
|
|
172
|
+
cat<<EOBASHRC > bashrc
|
|
173
|
+
#!/bin/bash
|
|
174
|
+
#
|
|
175
|
+
# Version $1 @ `date`
|
|
176
|
+
|
|
177
|
+
alias h=history
|
|
178
|
+
|
|
179
|
+
alias ls='ls -CF --color=auto'
|
|
180
|
+
alias ll='ls -lh'
|
|
181
|
+
alias lla='ls -lha'
|
|
182
|
+
alias glep='grep -l -s'
|
|
183
|
+
alias m=less
|
|
184
|
+
alias menv='env | sort | less'
|
|
185
|
+
|
|
186
|
+
alias whatsmyip='wget -qO- ifconfig.co'
|
|
187
|
+
|
|
188
|
+
alias err='wget -q -O- localhost:5111/logLevel/error'
|
|
189
|
+
alias wrn='wget -q -O- localhost:5111/logLevel/warn'
|
|
190
|
+
alias inf='wget -q -O- localhost:5111/logLevel/info'
|
|
191
|
+
alias dbg='wget -q -O- localhost:5111/logLevel/debug'
|
|
192
|
+
alias trc='wget -q -O- localhost:5111/logLevel/trace'
|
|
193
|
+
|
|
194
|
+
socks()
|
|
195
|
+
{
|
|
196
|
+
netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
cmetrics()
|
|
200
|
+
{
|
|
201
|
+
wget -qO- localhost:5111/metrics
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
cmstat()
|
|
205
|
+
{
|
|
206
|
+
wget -qO- localhost:5111\${1}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
cmclear()
|
|
210
|
+
{
|
|
211
|
+
cmstat /status/clear
|
|
212
|
+
}
|
|
213
|
+
EOBASHRC
|
|
214
|
+
} # end of create_bashrc
|
|
215
|
+
|
|
216
|
+
# Spilt a character delimited string and emit the object at the specified
|
|
217
|
+
# index. So passing a full registry string in like:
|
|
218
|
+
# us-docker.pkg.dev/leverege-registry/leverege
|
|
219
|
+
#
|
|
220
|
+
# the project name may be extracted by calling this like:
|
|
221
|
+
# getNthOvjectFromDelimitedString $registry 1 '/'
|
|
222
|
+
#
|
|
223
|
+
function getNthObjectFromDelimitedString() {
|
|
224
|
+
local inputStr=$1
|
|
225
|
+
local index=$2
|
|
226
|
+
local delimeter=$3
|
|
227
|
+
|
|
228
|
+
IFS=$delimeter
|
|
229
|
+
read -ra ADDR <<< "$inputStr"
|
|
230
|
+
|
|
231
|
+
echo ${ADDR[$index]}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
# ---------- MAIN PROCESSING STARTS HERE ----------
|
|
235
|
+
#
|
|
236
|
+
# make sure we have a current npmrc file
|
|
237
|
+
refresh-npm-token
|
|
238
|
+
|
|
239
|
+
# deprecation checks first...
|
|
240
|
+
deprecated=$(packageJson '.leverege.project')
|
|
241
|
+
if [ ! -z "$deprecated" ];
|
|
242
|
+
then
|
|
243
|
+
cat<<DEPRECATED_PROJECT
|
|
244
|
+
|
|
245
|
+
$(color y '***DEPRECATED: leverege.project setting in package.json')
|
|
246
|
+
|
|
247
|
+
Setting the project in the package.json leverege section was used for builds
|
|
248
|
+
being stored in the deprecated GCP container registry. Remove the deprecated
|
|
249
|
+
leverege.project setting from package.json and try again.
|
|
250
|
+
|
|
251
|
+
"leverege": {
|
|
252
|
+
$(color r "\"project\": \"$deprecated\",")
|
|
253
|
+
...
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
DEPRECATED_PROJECT
|
|
257
|
+
exit 1
|
|
258
|
+
fi
|
|
259
|
+
|
|
260
|
+
deprecated=$(packageJson '.leverege.container')
|
|
261
|
+
if [ ! -z "$deprecated" ];
|
|
262
|
+
then
|
|
263
|
+
cat<<DEPRECATED_CONTAINER
|
|
264
|
+
|
|
265
|
+
$(color y '***DEPRECATED: leverege.container is no longer supported')
|
|
266
|
+
|
|
267
|
+
Setting the container name explicitly from the package.json leverge block
|
|
268
|
+
is no longer supported. The container name will be automatically derived
|
|
269
|
+
from the git repository's remote root, which is the default behavior. Remove
|
|
270
|
+
the container line from the leverege section in package.json and try again.
|
|
271
|
+
|
|
272
|
+
"leverege": {
|
|
273
|
+
$(color r "\"container\": \"$deprecated\",")
|
|
274
|
+
...
|
|
275
|
+
}
|
|
276
|
+
DEPRECATED_CONTAINER
|
|
277
|
+
exit 1
|
|
278
|
+
fi
|
|
279
|
+
|
|
280
|
+
deprecated=$(packageJson '.leverege.nodeimg')
|
|
281
|
+
if [ ! -z "$deprecated" ];
|
|
282
|
+
then
|
|
283
|
+
cat<<DEPRECATED_NODEIMAGE
|
|
284
|
+
|
|
285
|
+
$(color y '***DEPRECATED: leverege.nodeimg is no longer supported')
|
|
286
|
+
|
|
287
|
+
Setting the node base image using the nodeimg statement in package.json is no
|
|
288
|
+
longer supported. By default the actual node image version will be defaulted
|
|
289
|
+
by this script and wil rarely need to be a specific version. Remove the
|
|
290
|
+
nodeimg line from the leverege section in package.json and try again.
|
|
291
|
+
|
|
292
|
+
"leverege": {
|
|
293
|
+
$(color r "\"nodeimg\": \"$deprecated\",")
|
|
294
|
+
...
|
|
295
|
+
}
|
|
296
|
+
DEPRECATED_NODEIMAGE
|
|
297
|
+
exit 1
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
deprecated=$(packageJson '.leverege.artifact')
|
|
301
|
+
if [ ! -z "$deprecated" ];
|
|
302
|
+
then
|
|
303
|
+
cat<<DEPRECATED_ARTIFACT
|
|
304
|
+
|
|
305
|
+
$(color y '***DEPRECATED: leverege.artifact is no longer supported')
|
|
306
|
+
|
|
307
|
+
Setting the artifact registry folder is no longer supported. Instead use the
|
|
308
|
+
$(color g leverege.registry) setting to specify the full artifact registry and folder
|
|
309
|
+
used for storing the docker image. Remove the artifact line from the leverege
|
|
310
|
+
section in package.json and try again.
|
|
311
|
+
|
|
312
|
+
"leverege": {
|
|
313
|
+
$(color r "\"artifact\": \"$deprecated\",")
|
|
314
|
+
...
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
$(color g "New syntax example:")
|
|
318
|
+
|
|
319
|
+
"leverege": {
|
|
320
|
+
$(color g "\"registry\": \"us-docker.pkg.dev/leverege-registry/$deprecated\",")
|
|
321
|
+
}
|
|
322
|
+
DEPRECATED_ARTIFACT
|
|
323
|
+
exit 1
|
|
324
|
+
fi
|
|
325
|
+
|
|
326
|
+
deprecated=$(packageJson '.leverege.nodeops')
|
|
327
|
+
if [ ! -z "$deprecated" ];
|
|
328
|
+
then
|
|
329
|
+
cat<<DEPRECATED_NODEOPS
|
|
330
|
+
|
|
331
|
+
$(color y '***DEPRECATED: leverege.nodeops are no longer supported')
|
|
332
|
+
|
|
333
|
+
Setting the hard coded node options on the image is no longer supported. The
|
|
334
|
+
better approach is to add $(color g 'NODE_OPTIONS') to the config section of the chart's
|
|
335
|
+
values.yaml to allow downstream users to easily tune the options as needed.
|
|
336
|
+
Remove the nodeops line from the leverege section in package.json and try again.
|
|
337
|
+
|
|
338
|
+
"leverege": {
|
|
339
|
+
$(color r "\"nodeops\": \"$deprecated\",")
|
|
340
|
+
...
|
|
341
|
+
}
|
|
342
|
+
DEPRECATED_NODEOPS
|
|
343
|
+
exit 1
|
|
344
|
+
fi
|
|
345
|
+
|
|
346
|
+
# the container name will be the git root for the repo
|
|
347
|
+
gitremote=`git config --get remote.origin.url`
|
|
348
|
+
if [ -z $gitremote ];
|
|
349
|
+
then
|
|
350
|
+
cat<<NOCONTAINER
|
|
351
|
+
|
|
352
|
+
$(color r '***ERROR: attempting to build an unnamed container')
|
|
353
|
+
|
|
354
|
+
You are attempting to create a docker image without a container name or
|
|
355
|
+
a git remote setup. Either define a $(color y 'container') statement in the leverege
|
|
356
|
+
section of package.json, or add a $(color g 'git remote') to this repository.
|
|
357
|
+
|
|
358
|
+
NOCONTAINER
|
|
359
|
+
exit 1
|
|
360
|
+
fi
|
|
361
|
+
container=$(basename $gitremote .git)
|
|
362
|
+
|
|
363
|
+
# build the registry specification
|
|
364
|
+
registry=$(packageJson '.leverege.registry')
|
|
365
|
+
if [ ! -z "$registry" ];
|
|
366
|
+
then
|
|
367
|
+
gcp_project="$(getNthObjectFromDelimitedString $registry 1 '/')"
|
|
368
|
+
registry_folder=$registry/images/$container
|
|
369
|
+
else
|
|
370
|
+
cat<<MISSING_REGISTRY
|
|
371
|
+
|
|
372
|
+
$(color r '***ERROR: the leverege.registry setting is required in package.json')
|
|
373
|
+
|
|
374
|
+
The $(color g 'leverege.registry') setting is now required and must be set to point to the
|
|
375
|
+
base URL of the artifact registry, plus the folder that the image is to be
|
|
376
|
+
stored in. For example, the Leverege Google project that contains our artifact
|
|
377
|
+
registry is $(color g 'leverege-registry') which contains several folders that are used to
|
|
378
|
+
group images by commonality. The stack services store their images in the
|
|
379
|
+
$(color g 'stack') folder, while general purpose services that we use may end up in the
|
|
380
|
+
$(color g 'leverege') folder.
|
|
381
|
+
|
|
382
|
+
Using api-server as an example, given this setting in api-server's package.json:
|
|
383
|
+
|
|
384
|
+
"leverege": {
|
|
385
|
+
$(color g '"registry": "us-docker.pkg.dev/leverege-registry/stack"')
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
the resultant docker image gets stored in:
|
|
389
|
+
|
|
390
|
+
$(color g 'us-docker.pkg.dev/leverege-registry/stack/images/api-server')
|
|
391
|
+
|
|
392
|
+
The helm/values.yaml file would then reference the same location:
|
|
393
|
+
|
|
394
|
+
image:
|
|
395
|
+
pullPolicy: IfNotPresent
|
|
396
|
+
registry: $(color g 'us-docker.pkg.dev/leverege-registry/leverege/images')
|
|
397
|
+
tag: ""
|
|
398
|
+
MISSING_REGISTRY
|
|
399
|
+
exit 1
|
|
400
|
+
fi
|
|
401
|
+
|
|
402
|
+
# verify the cloud build bucket exists
|
|
403
|
+
#
|
|
404
|
+
build_bucket="gs://${gcp_project}_cloudbuild"
|
|
405
|
+
gsutil ls -p $gcp_project -b $build_bucket &> /dev/null
|
|
406
|
+
if [ "$?" -ne 0 ];
|
|
407
|
+
then
|
|
408
|
+
cat<<MISSING_BUILD_BUCKET
|
|
409
|
+
|
|
410
|
+
$(color r "***ERROR: missing the cloud build bucket $build_bucket")
|
|
411
|
+
|
|
412
|
+
Go to Cloud Storage on the $(color g $gcp_project) GCP project and create the
|
|
413
|
+
target cloud build bucket before proceeding.
|
|
414
|
+
|
|
415
|
+
Build bucket => $(color g $build_bucket)
|
|
416
|
+
MISSING_BUILD_BUCKET
|
|
417
|
+
exit 1
|
|
418
|
+
fi
|
|
419
|
+
|
|
420
|
+
version=$1
|
|
421
|
+
[[ -f '.previous' ]] && previous=`cat .previous` || previous='FIRST BUILD'
|
|
422
|
+
#pckgver="v`node -p \"require('../package.json').version\"`"
|
|
423
|
+
pckgver="v$(packageJson '.version')"
|
|
424
|
+
pckgdts="`date +\"%Y%m%d-%H%M\"`"
|
|
425
|
+
# egrep was deprecated in 2007!
|
|
426
|
+
tagging=`echo $version | egrep -e "^v\d+\.\d+\.\d+$"`
|
|
427
|
+
|
|
428
|
+
if [ $tagging ];
|
|
429
|
+
then
|
|
430
|
+
if [[ `git status --porcelain` ]]; then
|
|
431
|
+
cat<<DIRTAG
|
|
432
|
+
|
|
433
|
+
$(color r '***ERROR: attempting to tag a non-beta dirty git repository')
|
|
434
|
+
|
|
435
|
+
You are attempting to create a tagged release image for pushing to the
|
|
436
|
+
container registry, but there are locally modified files. This is not
|
|
437
|
+
allowed since the applied tag will not be relevant to the image version
|
|
438
|
+
due to the pending commits.
|
|
439
|
+
|
|
440
|
+
Available options for proceeding:
|
|
441
|
+
|
|
442
|
+
$(color g '1) cleanly commit all local mods assuming relevance')
|
|
443
|
+
$(color y '2) eliminate unwanted local modifications')
|
|
444
|
+
$(color r '3) stash anything that is irrelevant to this release')
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
DIRTAG
|
|
448
|
+
exit 1
|
|
449
|
+
fi
|
|
450
|
+
|
|
451
|
+
# since we're tagging, the current branch must have an upstream
|
|
452
|
+
branch=`git rev-parse --abbrev-ref HEAD`
|
|
453
|
+
git rev-parse --abbrev-ref ${branch}@{u} &> /dev/null
|
|
454
|
+
|
|
455
|
+
if [ $? -ne 0 ];
|
|
456
|
+
then
|
|
457
|
+
cat<<NOUPSTR
|
|
458
|
+
|
|
459
|
+
$(color r '***ERROR: the current branch must have an upstream')
|
|
460
|
+
|
|
461
|
+
You are attempting to create a tagged release image for pushing to the
|
|
462
|
+
container registry, but the current branch does not have an upstream to
|
|
463
|
+
push to. This is not allowed since the applied tag will be stranded here
|
|
464
|
+
in your local repository, which is what we are attempting to avoid.
|
|
465
|
+
|
|
466
|
+
Available options for proceeding:
|
|
467
|
+
|
|
468
|
+
$(color g '1) set an upstream for this branch via:')
|
|
469
|
+
$(color g " git push --set-upstream origin ${branch}")
|
|
470
|
+
|
|
471
|
+
$(color y '2) rebase, squash and merge onto a branch with an upstream')
|
|
472
|
+
|
|
473
|
+
NOUPSTR
|
|
474
|
+
exit 1
|
|
475
|
+
fi
|
|
476
|
+
|
|
477
|
+
tagstat=$(color y 'will be tagged')
|
|
478
|
+
else
|
|
479
|
+
tagstat=$(color r 'BETA RELEASE WILL NOT BE TAGGED')
|
|
480
|
+
fi
|
|
481
|
+
|
|
482
|
+
pluggedIn=$(color g "no")
|
|
483
|
+
[ -f "${pluginFile}" ] && pluggedIn=$(color y "YES")
|
|
484
|
+
|
|
485
|
+
apkadds=$(packageJson '.leverege.apkadds')
|
|
486
|
+
runuser=$(packageJson '.leverege.runuser')
|
|
487
|
+
[ -z "${runuser}" ] && runuser='node'
|
|
488
|
+
|
|
489
|
+
npmlogging='--silent' # allow for verbose npm logs
|
|
490
|
+
if [ "$VERBOSE_DOCKREATE_NPM" == "yes" ];
|
|
491
|
+
then
|
|
492
|
+
npmlogging='--ddd'
|
|
493
|
+
else
|
|
494
|
+
hintverbose=1
|
|
495
|
+
fi
|
|
496
|
+
|
|
497
|
+
echo "Updating dependencies and workspace..." && npm install
|
|
498
|
+
if [ $? -ne 0 ];
|
|
499
|
+
then
|
|
500
|
+
cat<<INSTALLFAILED
|
|
501
|
+
|
|
502
|
+
$(color y 'npm install') $(color r 'FAILED') - fix it in order to proceed
|
|
503
|
+
|
|
504
|
+
INSTALLFAILED
|
|
505
|
+
exit 1
|
|
506
|
+
fi
|
|
507
|
+
|
|
508
|
+
cat<<IMGINFO
|
|
509
|
+
Project: $(color g $gcp_project)
|
|
510
|
+
Registry: $(color g $registry)
|
|
511
|
+
Container: $(color g $container)
|
|
512
|
+
Version: $(color g $version) $tagstat
|
|
513
|
+
Folder: $(color y $registry_folder)
|
|
514
|
+
NodeImage: $(color g $BASE_NODE_IMAGE)
|
|
515
|
+
AddedPkgs: $(color g $apkadds)
|
|
516
|
+
PluggedIn: ${pluggedIn}
|
|
517
|
+
Run User: $(color g $runuser)
|
|
518
|
+
Previous: $(color y $previous)
|
|
519
|
+
DateStamp: $(color g $pckgdts)
|
|
520
|
+
NPM Logs: $(color g $npmlogging)
|
|
521
|
+
|
|
522
|
+
IMGINFO
|
|
523
|
+
|
|
524
|
+
[ $hintverbose ] && printf " Define $(color g VERBOSE_DOCKREATE_NPM=\"yes\") for verbose build logging\n\n"
|
|
525
|
+
|
|
526
|
+
if [ "$pckgver" != "$version" ];
|
|
527
|
+
then
|
|
528
|
+
cat<<EOPKG
|
|
529
|
+
$(color y '***WARNING: specified version does not match package.json version' )
|
|
530
|
+
package.json => $(color g "$pckgver")
|
|
531
|
+
specified => $(color r "$version")
|
|
532
|
+
|
|
533
|
+
EOPKG
|
|
534
|
+
if [ $tagging ];
|
|
535
|
+
then
|
|
536
|
+
cat<<EONOPE
|
|
537
|
+
|
|
538
|
+
$(color r '... and you are attempting to release so NOPE!' )
|
|
539
|
+
|
|
540
|
+
EONOPE
|
|
541
|
+
exit 1
|
|
542
|
+
fi
|
|
543
|
+
fi
|
|
544
|
+
|
|
545
|
+
create_Dockerfile "$version" "$apkadds"
|
|
546
|
+
create_bashrc "$version"
|
|
547
|
+
|
|
548
|
+
rm -rf ./workspace && mkdir -p ./workspace
|
|
549
|
+
cp -rfp ${PKGTOP}/package*json ${PKGTOP}/dist/* ./workspace
|
|
550
|
+
|
|
551
|
+
# grab the npmrc token for the image
|
|
552
|
+
cp -f "$HOME/.npmrc" .npmrc
|
|
553
|
+
|
|
554
|
+
[ "$CIRCLECI" == "true" ] && exit 0
|
|
555
|
+
|
|
556
|
+
printf "Hit return to continue or ^C to exit\n\n"; read ANS
|
|
557
|
+
|
|
558
|
+
echo $version > .previous
|
|
559
|
+
|
|
560
|
+
echo "Changing Google Project to $project"
|
|
561
|
+
gcloud config set project $gcp_project
|
|
562
|
+
|
|
563
|
+
echo "Creating Docker Image for $registry_folder:$version"
|
|
564
|
+
echo " Building the workspace"
|
|
565
|
+
|
|
566
|
+
# use kaniko to cache builds
|
|
567
|
+
if [ "$USE_KANIKO" == "yes" ];
|
|
568
|
+
then
|
|
569
|
+
gcloud config set builds/use_kaniko True
|
|
570
|
+
else
|
|
571
|
+
gcloud config unset builds/use_kaniko
|
|
572
|
+
fi
|
|
573
|
+
|
|
574
|
+
# need a logging area outside of the default cloud build bucket in order
|
|
575
|
+
# to enable 3rd party builders from outside of leverege.com user space
|
|
576
|
+
build_logs="--gcs-log-dir $build_bucket/logs"
|
|
577
|
+
|
|
578
|
+
# submit the build request to gcloud with logs directed to the cloudbuild
|
|
579
|
+
# logging bucket from the docker directory
|
|
580
|
+
time gcloud builds submit $build_logs --tag $registry_folder:$version .
|
|
581
|
+
|
|
582
|
+
if [ $? -ne 0 ];
|
|
583
|
+
then
|
|
584
|
+
bldErr=$?
|
|
585
|
+
cat<<BUILDERR
|
|
586
|
+
|
|
587
|
+
$(color r '***ERROR: build failed! Aborting without tagging.')
|
|
588
|
+
|
|
589
|
+
The gcloud build process seems to have run into a problem. Please fix the
|
|
590
|
+
issue and rerun the dockerize process. This build will not be tagged, nor
|
|
591
|
+
will it be pushed.
|
|
592
|
+
|
|
593
|
+
BUILDERR
|
|
594
|
+
exit $bldErr
|
|
595
|
+
fi
|
|
596
|
+
|
|
597
|
+
# Tag the container with the node detailsand the culprit.
|
|
598
|
+
gcloud container images add-tag --quiet $registry_folder:$version \
|
|
599
|
+
$registry_folder:$pckgdts-$BASE_NODE_IMAGE-$USER \
|
|
600
|
+
$registry_folder:latest
|
|
601
|
+
|
|
602
|
+
if [ $tagging ];
|
|
603
|
+
then
|
|
604
|
+
printf "\n$(color g "Tagging and Pushing $version")\n"
|
|
605
|
+
git tag -af $1 -m "Docker version $1"
|
|
606
|
+
git push --follow-tags
|
|
607
|
+
else
|
|
608
|
+
printf "\n$(color y '*** Skipped git tagging - beta release')\n\n"
|
|
609
|
+
fi
|
|
610
|
+
|
|
611
|
+
cleanup
|
|
@@ -4,6 +4,13 @@ image:
|
|
|
4
4
|
config:
|
|
5
5
|
LOG_CONFIG: '{"type":"pino","level":"warn"}'
|
|
6
6
|
|
|
7
|
+
# CNPG overrides
|
|
8
|
+
# # stock pgsql
|
|
9
|
+
# MODEL_SQL_HOST: "db-postgres-stack-rw.cnpg-operands"
|
|
10
|
+
# PG_MODELS_HOST: "db-postgres-stack-rw.cnpg-operands"
|
|
11
|
+
# # timescale
|
|
12
|
+
# PG_HOST: "db-timescale-plain-ro.cnpg-operands"
|
|
13
|
+
|
|
7
14
|
autoscaling:
|
|
8
15
|
minReplicas: 3
|
|
9
16
|
maxReplicas: 12
|