Skip to content

Commit 3e73d5b

Browse files
committed
feat(mojaloop/#2092): upgrade nodeJS version for core services (#61) (#243)
feat(mojaloop/#2092): upgrade nodeJS version for core services - mojaloop/project#2092 - standardised CI scripts - updated docker-compose files to work correctly - fixed lint issues - updated .nvmrc to latest LTS version - added standard CI scripts/config to package.json: release, snapshot, standard-version, etc - updated gitignore to include standard IGNORE patterns - updated README with standard auto-release information - Fixed imports - Cleaned up Package.json - replaced npm-audit-resolves with audit-ci and added an applicable `audit-ci.jsonc` file with an audit allowList as per [mojaloop/design-authority-project/issues/92](mojaloop/design-authority-project#92) - added safeguards for uncaught promises as required by Node v16 or otherwise the process will terminate in such an advent (possibly due to the legacy RXJS dependency Notes: - Helm chart mountPaths need to be updated from `/opt/central-event-processor` to `/opt/app` as follows: ```YAML volumeMounts: - mountPath: /opt/app/config name: <deployment-name> ``` BREAKING CHANGE: Major version bump for node v16 LTS support, re-structuring of project directories to align to core Mojaloop repositories and docker image now uses `/opt/app` instead of `/opt/central-event-processor` which will impact config mounts.
1 parent 935dda9 commit 3e73d5b

24 files changed

+23466
-5089
lines changed

.circleci/config.yml

Lines changed: 497 additions & 82 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pids
1111
*.seed
1212
*.pid.lock
1313
.vscode
14-
package-lock.json
1514

1615
# Directory for instrumented libs generated by jscoverage/JSCover
1716
lib-cov
@@ -62,3 +61,11 @@ typings/
6261

6362
# next.js build output
6463
.next
64+
65+
# https://devspace.sh/
66+
devspace*
67+
.devspace/**.*
68+
69+
# Add ignores
70+
*IGNORE*
71+
*ignore*

.ncurc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
2+
reject: [
3+
]

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.15.0

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## @global-owner1 and @global-owner2 will be requested for
77
## review when someone opens a pull request.
88
#* @global-owner1 @global-owner2
9-
* @vgenev @mdebarros @elnyry-sam-k @lewisdaly @oderayi @shashi165
9+
* @vijayg10 @mdebarros @elnyry-sam-k
1010

1111
## Order is important; the last matching pattern takes the most
1212
## precedence. When someone opens a pull request that only

Dockerfile

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
FROM node:12.16.1-alpine as builder
2-
USER root
3-
4-
WORKDIR /opt/central-event-processor
1+
FROM node:16.15.0-alpine as builder
2+
WORKDIR /opt/app
53

64
RUN apk --no-cache add git
7-
RUN apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake \
8-
&& cd $(npm root -g)/npm \
9-
&& npm config set unsafe-perm true \
10-
&& npm install -g node-gyp
11-
12-
COPY package.json package-lock.json* /opt/central-event-processor/
5+
RUN apk add --no-cache -t build-dependencies make gcc g++ python3 libtool libressl-dev openssl-dev autoconf automake \
6+
&& cd $(npm root -g)/npm \
7+
&& npm config set unsafe-perm true \
8+
&& npm install -g node-gyp
139

14-
RUN npm install
10+
COPY package*.json /opt/app/
1511

16-
COPY src /opt/central-event-processor/src
17-
COPY config /opt/central-event-processor/config
18-
COPY app.js /opt/central-event-processor/
19-
COPY docs /opt/central-event-processor/docs
12+
RUN npm ci --production
2013

21-
FROM node:12.16.1-alpine
22-
WORKDIR /opt/central-event-processor
14+
FROM node:16.15.0-alpine
15+
WORKDIR /opt/app
2316

2417
# Create empty log file & link stdout to the application log file
2518
RUN mkdir ./logs && touch ./logs/combined.log
@@ -29,8 +22,10 @@ RUN ln -sf /dev/stdout ./logs/combined.log
2922
RUN adduser -D ml-user
3023
USER ml-user
3124

32-
COPY --chown=ml-user --from=builder /opt/central-event-processor .
33-
RUN npm prune --production
25+
COPY --chown=ml-user --from=builder /opt/app .
26+
27+
COPY src /opt/app/src
28+
COPY config /opt/app/config
3429

3530
EXPOSE 3080
36-
CMD node app.js
31+
CMD ["npm", "run", "start"]

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Copyright © 2020 Mojaloop Foundation
44

55
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0
6-
(the "License") and you may not use these files except in compliance with the [License](http://www.apache.org/licenses/LICENSE-2.0).
6+
(the "License") and you may not use these files except in compliance with the [License](http://www.apache.org/licenses/LICENSE-2.0).
77

88
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
99

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ The CEP can then be integrated with a notifier service, to send out notification
3939
- [Notifier flow (separate service)](#notifier-flow-separate-service)
4040
- [Auditing Dependencies](#auditing-dependencies)
4141
- [Container Scans](#container-scans)
42+
- [Automated Releases](#automated-releases)
43+
- [Potential problems](#potential-problems)
4244

4345
## Todo
4446

4547
- Improve code-coverage to 90% across the board: [.nycrc.yml](./.nycrc.yml). Don't forget to un-comment out the code-coverage options & rules.
48+
- Fix `TypeError: finalizer.unsubscribe is not a function` RXJS error
4649

4750
## Deployment
4851

@@ -215,3 +218,33 @@ For more information on anchore and anchore-cli, refer to:
215218

216219
- [Anchore CLI](https://github.com/anchore/anchore-cli)
217220
- [Circle Orb Registry](https://circleci.com/orbs/registry/orb/anchore/anchore-engine)
221+
222+
## Automated Releases
223+
224+
As part of our CI/CD process, we use a combination of CircleCI, standard-version
225+
npm package and github-release CircleCI orb to automatically trigger our releases
226+
and image builds. This process essentially mimics a manual tag and release.
227+
228+
On a merge to master, CircleCI is configured to use the mojaloopci github account
229+
to push the latest generated CHANGELOG and package version number.
230+
231+
Once those changes are pushed, CircleCI will pull the updated master, tag and
232+
push a release triggering another subsequent build that also publishes a docker image.
233+
234+
### Potential problems
235+
236+
- There is a case where the merge to master workflow will resolve successfully, triggering
237+
a release. Then that tagged release workflow subsequently failing due to the image scan,
238+
audit check, vulnerability check or other "live" checks.
239+
240+
This will leave master without an associated published build. Fixes that require
241+
a new merge will essentially cause a skip in version number or require a clean up
242+
of the master branch to the commit before the CHANGELOG and bump.
243+
244+
This may be resolved by relying solely on the previous checks of the
245+
merge to master workflow to assume that our tagged release is of sound quality.
246+
We are still mulling over this solution since catching bugs/vulnerabilities/etc earlier
247+
is a boon.
248+
249+
- It is unknown if a race condition might occur with multiple merges with master in
250+
quick succession, but this is a suspected edge case.

audit-ci.jsonc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json",
3+
// audit-ci supports reading JSON, JSONC, and JSON5 config files.
4+
// Only use one of ["low": true, "moderate": true, "high": true, "critical": true]
5+
"moderate": true,
6+
"allowlist": [ // NOTE: Please add as much information as possible to any items added to the allowList
7+
// Currently no fixes available for the following
8+
"GHSA-v88g-cgmw-v5xw",
9+
"GHSA-93q8-gq69-wqmw",
10+
"GHSA-fwr7-v2mv-hh25",
11+
"GHSA-phwq-j96m-2c2q",
12+
"GHSA-mhxj-85r3-2x55",
13+
"GHSA-v5vg-g7rq-363w",
14+
"GHSA-896r-f27r-55mw",
15+
"GHSA-282f-qqgm-c34q",
16+
"GHSA-6vfc-qv3f-vr6c",
17+
"GHSA-xvch-5gv4-984h",
18+
"GHSA-vh95-rmgr-6w4m",
19+
"GHSA-wc69-rhjr-hc9g",
20+
"GHSA-rp65-9cf3-cjxr",
21+
"GHSA-g954-5hwp-pp24",
22+
"GHSA-mjxr-4v3x-q3m4",
23+
"GHSA-rjqq-98f6-6j3r",
24+
"GHSA-w5p7-h5w8-2hfq",
25+
"GHSA-gcv8-gh4r-25x6",
26+
"GHSA-8h2f-7jc4-7m3m",
27+
"GHSA-3vjf-82ff-p4r3",
28+
"GHSA-gmv4-r438-p67f",
29+
"GHSA-p9pc-299p-vxgp"
30+
]
31+
}

audit-resolve.json

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)