Skip to content

Commit 6198f7b

Browse files
author
Simon Stone
committed
[FAB-16714] Add build.sh and start.sh scripts
Currently the build and start processing for Node.js chaincode is specified in the peer code (platform.go and dockercontroller.go). We want to move this into the Node.js chaincode code so that we can update the build and start processing without having to modify peer code. To achieve this, we will make it work just like Java chaincode - the peer will call out to build.sh and start.sh scripts. Need to add the scripts first, then update the peer code to use them. Signed-off-by: Simon Stone <sstone1@uk.ibm.com> Change-Id: I9452f34c128bff597a8af4379103bff92fe49349
1 parent f085675 commit 6198f7b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

fabric-nodeenv/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ RUN apk add --no-cache \
1010
g++;
1111
RUN mkdir -p /chaincode/input \
1212
&& mkdir -p /chaincode/output \
13-
&& mkdir -p /usr/local/src;
13+
&& mkdir -p /usr/local/src;
14+
ADD build.sh start.sh /chaincode/

fabric-nodeenv/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
set -ex
6+
INPUT_DIR=/chaincode/input
7+
OUTPUT_DIR=/chaincode/output
8+
cp -R ${INPUT_DIR}/src/. ${OUTPUT_DIR}
9+
cd ${OUTPUT_DIR}
10+
if [ -f package-lock.json -o -f npm-shrinkwrap.json ]; then
11+
npm ci --only=production
12+
else
13+
npm install --production
14+
fi

fabric-nodeenv/start.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
set -ex
6+
CHAINCODE_DIR=/usr/local/src
7+
cd ${CHAINCODE_DIR}
8+
npm start -- "$@"

0 commit comments

Comments
 (0)