diff --git a/fabric-nodeenv/Dockerfile b/fabric-nodeenv/Dockerfile index bf91ebd8..ee8cf607 100644 --- a/fabric-nodeenv/Dockerfile +++ b/fabric-nodeenv/Dockerfile @@ -10,4 +10,5 @@ RUN apk add --no-cache \ g++; RUN mkdir -p /chaincode/input \ && mkdir -p /chaincode/output \ - && mkdir -p /usr/local/src; \ No newline at end of file + && mkdir -p /usr/local/src; +ADD build.sh start.sh /chaincode/ \ No newline at end of file diff --git a/fabric-nodeenv/build.sh b/fabric-nodeenv/build.sh new file mode 100755 index 00000000..09e6c8de --- /dev/null +++ b/fabric-nodeenv/build.sh @@ -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 \ No newline at end of file diff --git a/fabric-nodeenv/start.sh b/fabric-nodeenv/start.sh new file mode 100755 index 00000000..e5258ff0 --- /dev/null +++ b/fabric-nodeenv/start.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# +# SPDX-License-Identifier: Apache-2.0 +# +set -ex +CHAINCODE_DIR=/usr/local/src +cd ${CHAINCODE_DIR} +npm start -- "$@" \ No newline at end of file