Skip to content

Commit

Permalink
[FAB-16714] Add build.sh and start.sh scripts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Simon Stone committed Oct 1, 2019
1 parent f085675 commit 6198f7b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fabric-nodeenv/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ RUN apk add --no-cache \
g++;
RUN mkdir -p /chaincode/input \
&& mkdir -p /chaincode/output \
&& mkdir -p /usr/local/src;
&& mkdir -p /usr/local/src;
ADD build.sh start.sh /chaincode/
14 changes: 14 additions & 0 deletions fabric-nodeenv/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# SPDX-License-Identifier: Apache-2.0
#
set -ex
INPUT_DIR=/chaincode/input
OUTPUT_DIR=/chaincode/output
cp -R ${INPUT_DIR}/src/. ${OUTPUT_DIR}
cd ${OUTPUT_DIR}
if [ -f package-lock.json -o -f npm-shrinkwrap.json ]; then
npm ci --only=production
else
npm install --production
fi
8 changes: 8 additions & 0 deletions fabric-nodeenv/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
#
# SPDX-License-Identifier: Apache-2.0
#
set -ex
CHAINCODE_DIR=/usr/local/src
cd ${CHAINCODE_DIR}
npm start -- "$@"

0 comments on commit 6198f7b

Please sign in to comment.