Skip to content

Commit 44c95bd

Browse files
Use Node 20 runtime in Docker image (#410)
- Code remains compatible with Node 18. - Project continues to be built and tested with Node 18. - Node 20 is used as the runtime for the nodeenv Docker image to allow chaincode access to latest Node features and security fixes. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent a1f421b commit 44c95bd

File tree

28 files changed

+150
-137
lines changed

28 files changed

+150
-137
lines changed

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repository:
55
homepage: https://wiki.hyperledger.org/display/fabric
66
default_branch: main
77
has_downloads: true
8-
has_issues: false
8+
has_issues: true
99
has_projects: false
1010
has_wiki: false
1111
archived: false

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
name: Pull request success
2323
runs-on: ubuntu-latest
2424
steps:
25-
- run: true
25+
- run: 'true'

.github/workflows/release.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
workflow_dispatch:
1111

1212
env:
13-
CHAINCODE_CONTAINER_NODE_VER: 18
1413
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }}
1514

1615
jobs:
@@ -47,15 +46,13 @@ jobs:
4746
steps:
4847
- name: Set up QEMU
4948
uses: docker/setup-qemu-action@v3
50-
5149
- name: Set up Docker Buildx
5250
uses: docker/setup-buildx-action@v3
5351
with:
5452
buildkitd-flags: --debug
5553
config-inline: |
5654
[worker.oci]
5755
max-parallelism = 1
58-
5956
- name: Checkout
6057
uses: actions/checkout@v4
6158

@@ -86,5 +83,3 @@ jobs:
8683
tags: ${{ steps.meta.outputs.tags }}
8784
push: ${{ github.event_name != 'pull_request' }}
8885
labels: ${{ steps.meta.outputs.labels }}
89-
build-args: |
90-
NODE_VER=${{ env.CHAINCODE_CONTAINER_NODE_VER }}

.github/workflows/test.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
BUILD_DATE: ${{ steps.builddata.outputs.BUILD_DATE }}
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: '18.x'
2118
- name: BuildData
2219
id: builddata
2320
run: |
@@ -41,7 +38,6 @@ jobs:
4138
4239
build:
4340
runs-on: ubuntu-20.04
44-
4541
steps:
4642
- uses: actions/checkout@v4
4743
- uses: actions/setup-node@v4
@@ -61,19 +57,16 @@ jobs:
6157
with:
6258
name: TestResults
6359
path: ./**/test-results.xml
64-
6560
- name: Build Binaries
6661
run: |
6762
set -xev
6863
node common/scripts/install-run-rush.js publish --include-all --pack --release-folder tgz --publish
6964
docker image save hyperledger/fabric-nodeenv | gzip > fabric-nodeenv.tar.gz
70-
7165
- uses: actions/upload-artifact@v4
7266
name: Binaries
7367
with:
7468
name: node-tgzs
7569
path: tgz/
76-
7770
- uses: actions/upload-artifact@v4
7871
name: Docker
7972
with:
@@ -88,7 +81,6 @@ jobs:
8881
- uses: actions/setup-node@v4
8982
with:
9083
node-version: '18.x'
91-
9284
- uses: actions/download-artifact@v4
9385
with:
9486
name: nodeenv-docker-image
@@ -97,7 +89,6 @@ jobs:
9789
with:
9890
name: node-tgzs
9991
path: build/
100-
10192
- name: Setup the fv build
10293
env:
10394
PIPELINE_WORKSPACE: workspace
@@ -111,7 +102,6 @@ jobs:
111102
node common/scripts/install-run-rush.js update # should the tests need 'building' this will need to go here
112103
node common/scripts/install-run-rush.js start-fabric
113104
node common/scripts/install-run-rush.js start-verdaccio # script will check for the ci variable and use built images
114-
115105
- name: Run the FV Tests
116106
run: |
117107
set -xev
@@ -120,7 +110,6 @@ jobs:
120110
121111
node common/scripts/install-run-rush.js test:fv --verbose
122112
node common/scripts/install-run-rush.js test:e2e --verbose
123-
124113
- uses: actions/upload-artifact@v4
125114
if: ${{ !cancelled() }}
126115
name: TestLogs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ yarn.lock
1414
**/typescript/*.js.map
1515

1616
fabric*.tgz
17+
install-fabric.sh
1718

1819
libraries/fabric-ledger/lib
1920

@@ -28,6 +29,7 @@ common/temp/**
2829
**/.rush/temp/**
2930
**/*.build.error.log
3031
**/*.build.log
32+
**/*.test_fv.log
3133

3234
package-deps.json
3335
test-results.xml

COMPATIBILITY.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ Github is used for code base management, issues should reported in the repositor
66

77
This table shows the summary of the compatibility of the Node modules at versions 1.4 and 2.x, together with the Node.js runtime they require and the Fabric Peer versions they can communicate with.
88

9-
| | Peer Connectivity v1.4 | Supported NodeJS | Peer Connectivity v2.x |
10-
| ------------------------------ | ---------------------- | ---------------- | ---------------------- |
11-
| Node modules **v1.4.5** | Yes | 8 | Yes |
12-
| Node modules **v2.2.x/v2.3.x** | Yes | 12 | Yes |
13-
| Node modules **v2.4.x** | Yes | 16 | Yes |
14-
| Node modules **v2.5.x** | Yes | 18 | Yes |
9+
| Chaincode Docker image | Peer connectivity v1.4 | Peer connectivity v2.x | Minimum supported Node.js | Node.js runtime |
10+
| --- | --- | --- | --- | --- |
11+
| **v1.4.5** | Yes | Yes | 8 | 8 |
12+
| **v2.2.x** | Yes | Yes | 12 | 12 |
13+
| **v2.3.x** | Yes | Yes | 12 | 12 |
14+
| **v2.4.x** | Yes | Yes | 16 | 16 |
15+
| **v2.5.0** - **v2.5.4** | Yes | Yes | 18 | 18 |
16+
| **v2.5.5+** | Yes | Yes | 18 | 20 |
1517

18+
Whilst these are defaults based on the corresponding `fabric-nodeenv` Docker image version, the Docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the desired Docker image and version.
1619

17-
* Fabric peer v1.4 will create a Node.js v8 runtime
18-
* Fabric peer v2.2/2.3 will create a Node.js 12 runtime
19-
* Fabric peer v2.4 will create a Node.js 16 runtime
20-
* Fabric peer v2.5 will create a Node.js 18 runtime
21-
22-
Whilst these are defaults based on the corresponding `fabric-nodeenv` docker image version, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the desired docker image and version.
23-
24-
For example `CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.2` will allow the use of the latest Node 12 runtime to be used within a Peer v1.4.
20+
For example `CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.2` will allow the use of a Node 12 runtime to be used within a Peer v1.4.
2521

2622
The Node chaincode modules will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Node.js 8 runtime, if a Node.js 12 runtime was configured, the node chaincode modules at v2.x still function when connecting to the Fabric Peer v1.4.
2723

@@ -39,7 +35,7 @@ The key elements are :
3935
- the version of the Node.js runtime used to run the code
4036
- When starting a chaincode container to run a Smart Contract, the version of the runtime that is used is determined by these factors:
4137

42-
Fabric v1.4.x, and Fabric v2.x will, by default, start up a docker container based on `fabric-nodeenv` to host the chaincode and contracts. The version of the docker image used is driven by the version of Fabric in use, but can be overridden by setting the peer's `CORE_CHAINCODE_NODE_RUNTIME` environment variable.
38+
Fabric v1.4.x, and Fabric v2.x will, by default, start up a Docker container based on `fabric-nodeenv` to host the chaincode and contracts. The version of the Docker image used is driven by the version of Fabric in use, but can be overridden by setting the peer's `CORE_CHAINCODE_NODE_RUNTIME` environment variable.
4339

4440
With Fabric v2.x, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric.
4541

@@ -50,19 +46,20 @@ Node modules that are produced are `fabric-contract-api`, `fabric-shim` & `fabri
5046
* Fabric v1.4 Node.js chaincode modules are supported running Nodejs 8.16.1 with the x86_64 architecture.
5147
* Fabric v2.2/v2.3 Node.js chaincode modules are supported running in Node.js 12.22.6, with the x86_64 architecture.
5248
* Fabric v2.4 Node.js chaincode modules are supported running in Node.js 16.x, with the x86_64 architecture.
53-
* Fabric v2.5 Node.js chaincode modules are supported running in Node.js 18.x, with the x86_64 and arm64 architectures.
49+
* Fabric v2.5.x Node.js chaincode modules are supported running in Node.js 18.x, with the x86_64 and arm64 architectures.
5450

55-
Architecture Support: all docker images, runtimes, tools are tested under x86_64 ONLY
51+
Architecture Support: all Docker images, runtimes, tools are tested under x86_64 ONLY
5652

5753
### Default Peer Runtime selection
5854

59-
* Fabric 2.2/2.3 `fabric-nodeenv` docker image is based on node:12.22.6-alpine.
60-
* Fabric 2.4 `fabric-nodeenv` docker image is based on node:16-alpine.
61-
* Fabric 2.5 `fabric-nodeenv` docker image is based on node:18-alpine.
55+
* Fabric 2.2/2.3 `fabric-nodeenv` Docker image is based on node:12.22.6-alpine.
56+
* Fabric 2.4 `fabric-nodeenv` Docker image is based on node:16-alpine.
57+
* Fabric 2.5.0 - 2.5.4 `fabric-nodeenv` Docker image is based on node:18-alpine.
58+
* Fabric 2.5.5+ `fabric-nodeenv` Docker image is based on node:20-alpine.
6259

63-
*Note:* With the default docker image used by Fabric 2.x, the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used. 
60+
*Note:* With the default Docker image used by Fabric 2.x, the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used. 
6461

65-
When using Fabric 1.4.x, the docker image that is used to run the Node.js chaincode is node v8.16.1. It is installed with npm install --production
62+
When using Fabric 1.4.x, the Docker image that is used to run the Node.js chaincode is node v8.16.1. It is installed with npm install --production
6663

6764
### Supported Runtime communication with the Peer
6865

TUTORIAL.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ The dependencies of `fabric-contract-api` and `fabric-shim` will be required.
1515
"name": "chaincode",
1616
"description": "My first exciting chaincode implemented in node.js",
1717
"engines": {
18-
"node": "^12.16.1",
19-
"npm": "^6.4.1"
18+
"node": ">=18"
2019
},
2120
"scripts": {
2221
"test": "mocha....."

common/scripts/install-run-rush-pnpm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/scripts/install-run-rush.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/scripts/install-run-rushx.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)