-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add external builders for golang and node chaincode to test-network-n…
…ano-bash The external builders will build and launch binary chaincode instead of docker containers. Signed-off-by: Chris Elder <celder628@gmail.com>
- Loading branch information
Chris Elder
committed
Jun 5, 2024
1 parent
e4af8fe
commit 5420c5f
Showing
14 changed files
with
227 additions
and
10 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
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,6 @@ | ||
mkdir -p config | ||
|
||
cp ../config/configtx.yaml ./config/configtx.yaml | ||
cp ../config/orderer.yaml ./config/orderer.yaml | ||
sed -e '/externalBuilders:/r ./external_builders/core_yaml_change.yaml' ../config/core.yaml | sed -e "s|_working_dir_|$PWD|g" > ./config/core.yaml | ||
|
12 changes: 12 additions & 0 deletions
12
test-network-nano-bash/external_builders/core_yaml_change.yaml
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,12 @@ | ||
- name: golang | ||
path: _working_dir_/external_builders/golang | ||
propagateEnvironment: | ||
- GOCACHE | ||
- GOENV | ||
- HOME | ||
- GOPROXY | ||
- name: node | ||
path: _working_dir_/external_builders/node | ||
propagateEnvironment: | ||
- HOME | ||
- npm_config_cache |
11 changes: 11 additions & 0 deletions
11
test-network-nano-bash/external_builders/golang/bin/detect
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,11 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -euo pipefail | ||
exec 1>&2 | ||
CHAINCODE_METADATA_DIR="$2" | ||
if [ "$(jq -r .type "${CHAINCODE_METADATA_DIR}/metadata.json" | tr '[:upper:]' '[:lower:]')" = "golang" ]; then | ||
exit 0 | ||
fi | ||
exit 1 |
12 changes: 12 additions & 0 deletions
12
test-network-nano-bash/external_builders/golang/bin/release
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,12 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -xeuo pipefail | ||
exec 1>&2 | ||
|
||
BUILD_OUTPUT_DIR="$1" | ||
RELEASE_OUTPUT_DIR="$2" | ||
if [ -d "${BUILD_OUTPUT_DIR}/META-INF" ] ; then | ||
cp -a "${BUILD_OUTPUT_DIR}/META-INF/"* "${RELEASE_OUTPUT_DIR}/" | ||
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,55 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -xeuo pipefail | ||
exec 1>&2 | ||
BUILD_OUTPUT_DIR="$1" | ||
RUN_METADATA_DIR="$2" | ||
|
||
####################################### | ||
# Export environment variables and extract certificate files from chaincode.json | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# METADATA_DIR: Location of the chaincode.json file | ||
# Returns: | ||
# None | ||
####################################### | ||
function process_chaincode_metadata_json { | ||
local METADATA_DIR=${RUN_METADATA_DIR} | ||
|
||
CORE_CHAINCODE_ID_NAME="$(jq -r .chaincode_id "$METADATA_DIR/chaincode.json")" | ||
CORE_PEER_ADDRESS="$(jq -r .peer_address "$METADATA_DIR/chaincode.json")" | ||
CORE_PEER_LOCALMSPID="$(jq -r .mspid "$METADATA_DIR/chaincode.json")" | ||
export CORE_CHAINCODE_ID_NAME | ||
export CORE_PEER_ADDRESS | ||
export CORE_PEER_LOCALMSPID | ||
|
||
if [ -z "$(jq -r .client_cert "$METADATA_DIR/chaincode.json")" ]; then | ||
CORE_PEER_TLS_ENABLED="false" | ||
export CORE_PEER_TLS_ENABLED | ||
else | ||
CORE_PEER_TLS_ENABLED="true" | ||
CORE_TLS_CLIENT_CERT_FILE="$BUILD_OUTPUT_DIR/client.crt" | ||
CORE_TLS_CLIENT_KEY_FILE="$BUILD_OUTPUT_DIR/client.key" | ||
CORE_PEER_TLS_ROOTCERT_FILE="$BUILD_OUTPUT_DIR/root.crt" | ||
export CORE_PEER_TLS_ENABLED | ||
export CORE_TLS_CLIENT_CERT_FILE | ||
export CORE_TLS_CLIENT_KEY_FILE | ||
export CORE_PEER_TLS_ROOTCERT_FILE | ||
|
||
jq -r .client_cert "$METADATA_DIR/chaincode.json" >"$CORE_TLS_CLIENT_CERT_FILE" | ||
jq -r .client_key "$METADATA_DIR/chaincode.json" >"$CORE_TLS_CLIENT_KEY_FILE" | ||
jq -r .root_cert "$METADATA_DIR/chaincode.json" >"$CORE_PEER_TLS_ROOTCERT_FILE" | ||
fi | ||
} | ||
|
||
# extract the required environment variables | ||
process_chaincode_metadata_json | ||
|
||
# output for debug purposes | ||
env | grep CORE | sort | ||
|
||
|
||
exec "${BUILD_OUTPUT_DIR}/chaincode" -peer.address="${CORE_PEER_ADDRESS}" |
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,11 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -euo pipefail | ||
exec 1>&2 | ||
CHAINCODE_METADATA_DIR="$2" | ||
if [ "$(jq -r .type "${CHAINCODE_METADATA_DIR}/metadata.json" | tr '[:upper:]' '[:lower:]')" = "node" ]; 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,11 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -euo pipefail | ||
exec 1>&2 | ||
BUILD_OUTPUT_DIR="$1" | ||
RELEASE_OUTPUT_DIR="$2" | ||
if [ -d "${BUILD_OUTPUT_DIR}/META-INF" ] ; then | ||
cp -a "${BUILD_OUTPUT_DIR}/META-INF/"* "${RELEASE_OUTPUT_DIR}/" | ||
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,51 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
set -xeuo pipefail | ||
exec 1>&2 | ||
|
||
BUILD_OUTPUT_DIR="$1" | ||
RUN_METADATA_DIR="$2" | ||
|
||
cd "${BUILD_OUTPUT_DIR}" | ||
ls -lart | ||
|
||
# extract the id, mspid, and peer address | ||
CORE_CHAINCODE_ID_NAME="$(jq -r .chaincode_id "${RUN_METADATA_DIR}/chaincode.json")" | ||
CORE_PEER_LOCALMSPID="$(jq -r .mspid "${RUN_METADATA_DIR}/chaincode.json")" | ||
CORE_PEER_ADDRESS="$(jq -r .peer_address "${RUN_METADATA_DIR}/chaincode.json")" | ||
export CORE_CHAINCODE_ID_NAME CORE_PEER_LOCALMSPID CORE_PEER_ADDRESS | ||
|
||
# process the TLS options if needed | ||
if [ -z "$(jq -r .client_cert "$RUN_METADATA_DIR/chaincode.json")" ]; then | ||
CORE_PEER_TLS_ENABLED="false" | ||
export CORE_PEER_TLS_ENABLED | ||
else | ||
|
||
export CORE_PEER_TLS_ENABLED="true" | ||
export CORE_TLS_CLIENT_CERT_FILE="$BUILD_OUTPUT_DIR/client-pem.crt" | ||
export CORE_TLS_CLIENT_KEY_FILE="$BUILD_OUTPUT_DIR/client-pem.key" | ||
export CORE_TLS_CLIENT_CERT_PATH="$BUILD_OUTPUT_DIR/client.crt" | ||
export CORE_TLS_CLIENT_KEY_PATH="$BUILD_OUTPUT_DIR/client.key" | ||
|
||
export CORE_PEER_TLS_ROOTCERT_FILE="$BUILD_OUTPUT_DIR/root.crt" | ||
|
||
jq -r .client_cert "$RUN_METADATA_DIR/chaincode.json" > "$CORE_TLS_CLIENT_CERT_FILE" | ||
jq -r .client_key "$RUN_METADATA_DIR/chaincode.json" > "$CORE_TLS_CLIENT_KEY_FILE" | ||
jq -r .root_cert "$RUN_METADATA_DIR/chaincode.json" > "$CORE_PEER_TLS_ROOTCERT_FILE" | ||
|
||
base64 -i "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}" | ||
base64 -i "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}" | ||
|
||
#base64 -w 0 "${CORE_TLS_CLIENT_CERT_FILE}" > "${CORE_TLS_CLIENT_CERT_PATH}" | ||
#base64 -w 0 "${CORE_TLS_CLIENT_KEY_FILE}" > "${CORE_TLS_CLIENT_KEY_PATH}" | ||
|
||
ls -lart "$BUILD_OUTPUT_DIR" | ||
fi | ||
|
||
# output for debug purposes | ||
env | grep CORE | sort | ||
|
||
# run the chaincode | ||
exec npm start -- --peer.address="${CORE_PEER_ADDRESS}" |
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