-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from hyperledger-labs/develop
Support ccaas deployment
- Loading branch information
Showing
27 changed files
with
973 additions
and
50 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,18 @@ | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
ARG GO_VER=1.21 | ||
ARG ALPINE_VER=3.20 | ||
ARG CC_SERVER_PORT=9999 | ||
|
||
FROM golang:${GO_VER}-alpine${ALPINE_VER} | ||
|
||
WORKDIR /go/src/github.com/hyperledger-labs/cc-tools-demo | ||
COPY . . | ||
|
||
RUN go get -d -v . | ||
RUN go build -o cc-tools-demo -v . | ||
|
||
EXPOSE ${CC_SERVER_PORT} | ||
CMD ["./cc-tools-demo"] |
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
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
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,21 @@ | ||
#!/bin/bash | ||
|
||
# set -euo pipefail | ||
|
||
SOURCE=$1 | ||
OUTPUT=$3 | ||
|
||
#external chaincodes expect connection.json file in the chaincode package | ||
if [ ! -f "$SOURCE/connection.json" ]; then | ||
>&2 echo "$SOURCE/connection.json not found" | ||
exit 1 | ||
fi | ||
|
||
#simply copy the endpoint information to specified output location | ||
cp $SOURCE/connection.json $OUTPUT/connection.json | ||
|
||
if [ -d "$SOURCE/metadata" ]; then | ||
cp -a $SOURCE/metadata $OUTPUT/metadata | ||
fi | ||
|
||
exit 0 |
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,14 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
METADIR=$2 | ||
# check if the "type" field is set to "external" | ||
# crude way without jq which is not in the default fabric peer image | ||
TYPE=$(tr -d '\n' < "$METADIR/metadata.json" | awk -F':' '{ for (i = 1; i < NF; i++){ if ($i~/type/) { print $(i+1); break }}}'| cut -d\" -f2) | ||
|
||
if [ "$TYPE" = "external" ]; then | ||
exit 0 | ||
fi | ||
|
||
exit 1 |
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,38 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
BLD="$1" | ||
RELEASE="$2" | ||
|
||
if [ -d "$BLD/metadata" ]; then | ||
cp -a "$BLD/metadata/"* "$RELEASE/" | ||
fi | ||
|
||
#external chaincodes expect artifacts to be placed under "$RELEASE"/chaincode/server | ||
if [ -f $BLD/connection.json ]; then | ||
mkdir -p "$RELEASE"/chaincode/server | ||
|
||
sed -i "s/{{.org}}/$CCAAS_ORG/" $BLD/connection.json | ||
sed -i "s/{{.port}}/$CCAAS_PORT/" $BLD/connection.json | ||
|
||
# Check if tls is enabled | ||
if [ "$(jq -r .tls_required $BLD/connection.json)" = "true" ]; then | ||
client_cert=$(awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' "$CCAAS_CLIENT_CERT_FILE") | ||
client_key=$(awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' "$CCAAS_CLIENT_KEY_FILE") | ||
root_cert=$(awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' "$CCAAS_ROOT_CERT_FILE") | ||
|
||
# Add certs files to connection.json | ||
echo $(jq ".client_cert=\"$client_cert\"" $BLD/connection.json) > $BLD/connection.json | ||
echo $(jq ".client_key=\"$client_key\"" $BLD/connection.json) > $BLD/connection.json | ||
echo $(jq ".root_cert=\"$root_cert\"" $BLD/connection.json) > $BLD/connection.json | ||
fi | ||
|
||
cp $BLD/connection.json "$RELEASE"/chaincode/server | ||
|
||
exit 0 | ||
fi | ||
|
||
exit 1 | ||
|
||
|
Oops, something went wrong.