forked from hyperledger/fabric-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding examples of CCAAS and support into the test-network (hyperledg…
…er#560) - Updated the test-network with examples of runnig CCAAS - Updating the asset transfer basic with how to run chaincode as a service. Signed-off-by: Matthew B White <[email protected]>
- Loading branch information
Showing
18 changed files
with
6,058 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# the first stage | ||
FROM gradle:jdk11 AS GRADLE_BUILD | ||
ARG CC_SERVER_PORT | ||
|
||
# copy the build.gradle and src code to the container | ||
COPY src/ src/ | ||
COPY build.gradle ./ | ||
|
||
# Build and package our code | ||
RUN gradle --no-daemon build shadowJar -x checkstyleMain -x checkstyleTest | ||
|
||
|
||
# the second stage of our build just needs the compiled files | ||
FROM openjdk:11-jre | ||
|
||
# Setup tini to work better handle signals | ||
ENV TINI_VERSION v0.19.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
RUN chmod +x /tini | ||
|
||
RUN addgroup --system javauser && useradd -g javauser javauser | ||
|
||
# copy only the artifacts we need from the first stage and discard the rest | ||
COPY --chown=javauser:javauser --from=GRADLE_BUILD /home/gradle/build/libs/chaincode.jar /chaincode.jar | ||
COPY --chown=javauser:javauser docker/docker-entrypoint.sh /docker-entrypoint.sh | ||
|
||
ENV PORT $CC_SERVER_PORT | ||
EXPOSE $CC_SERVER_PORT | ||
|
||
USER javauser | ||
ENTRYPOINT [ "/tini", "--", "/docker-entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
asset-transfer-basic/chaincode-java/docker/docker-entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -euo pipefail | ||
: ${CORE_PEER_TLS_ENABLED:="false"} | ||
: ${DEBUG:="false"} | ||
|
||
if [ "${DEBUG,,}" = "true" ]; then | ||
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000 -jar /chaincode.jar | ||
elif [ "${CORE_PEER_TLS_ENABLED,,}" = "true" ]; then | ||
java -jar /chaincode.jar # todo | ||
else | ||
java -jar /chaincode.jar | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
FROM node:16 AS builder | ||
ARG CC_SERVER_PORT | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy node.js source and build, changing owner as well | ||
COPY --chown=node:node . /usr/src/app | ||
RUN npm ci && npm run package | ||
|
||
|
||
FROM node:16 AS production | ||
|
||
# Setup tini to work better handle signals | ||
ENV TINI_VERSION v0.19.0 | ||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
RUN chmod +x /tini | ||
|
||
|
||
WORKDIR /usr/src/app | ||
COPY --chown=node:node --from=builder /usr/src/app/dist ./dist | ||
COPY --chown=node:node --from=builder /usr/src/app/package.json ./ | ||
COPY --chown=node:node --from=builder /usr/src/app/npm-shrinkwrap.json ./ | ||
COPY --chown=node:node docker/docker-entrypoint.sh /usr/src/app/docker-entrypoint.sh | ||
RUN npm ci --only=production | ||
|
||
ENV PORT $CC_SERVER_PORT | ||
EXPOSE $CC_SERVER_PORT | ||
ENV NODE_ENV=production | ||
|
||
USER node | ||
ENTRYPOINT [ "/tini", "--", "/usr/src/app/docker-entrypoint.sh" ] |
16 changes: 16 additions & 0 deletions
16
asset-transfer-basic/chaincode-typescript/docker/docker-entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -euo pipefail | ||
: ${CORE_PEER_TLS_ENABLED:="false"} | ||
: ${DEBUG:="false"} | ||
|
||
if [ "${DEBUG,,}" = "true" ]; then | ||
npm run start:server-debug | ||
elif [ "${CORE_PEER_TLS_ENABLED,,}" = "true" ]; then | ||
npm run start:server | ||
else | ||
npm run start:server-nontls | ||
fi | ||
|
Oops, something went wrong.