-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-4197][FAB-4198] examples/cluster improvements
This patch enhances the examples/cluster facility as follows: 1) assets are now generated statically 2) We can use an arbitrary docker tag rather than assume :latest (1) Means that "make compose" will now generate a docker-compose configuration that may be used outside of the examples/cluster environment. E.g. once "make compose" completes, the user may manage the docker-composition however they like. (2) Means that we can now direct the tooling to generate arbibrary tags (e.g. x86_64-1.0.0) rather than assuming :latest. We also added a few more knobs, like the ability to point to a completely different docker namespace (with DOCKER_NS=hyperledger the default). Fixes FAB-4197 and FAB-4198 Change-Id: Ibfac70680b4af5c119aa6e2e3adb01773378cfe0 Signed-off-by: Greg Haskins <[email protected]> Signed-off-by: Gari Singh <[email protected]>
- Loading branch information
Showing
6 changed files
with
107 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,11 @@ mspmap.peer3 := $(PEER_PATH)/peer3.org1.net | |
mspmap.peer4 := $(PEER_PATH)/peer4.org1.net | ||
mspmap.cli := $(USERS_PATH)/[email protected] | ||
|
||
COMPOSE=docker-compose -f compose/docker-compose.yaml | ||
DRUN=$(COMPOSE) run --rm cli | ||
|
||
RELEASE ?= latest | ||
CA_RELEASE ?= $(RELEASE) | ||
FABRIC_RELEASE ?= $(RELEASE) | ||
DOCKER_NS ?= hyperledger | ||
TLS ?= true | ||
export TLS_ENABLED=$(TLS) | ||
|
||
CRYPTOGEN=build/bin/cryptogen | ||
CONFIGTXGEN=build/bin/configtxgen | ||
|
@@ -48,15 +48,8 @@ pkgmap.configtxgen := $(FABRICPKG)/common/configtx/tool/configtxgen | |
help: | ||
@cat usage.txt | ||
|
||
compose-up: nodes | ||
@echo "Booting docker-compose environment" | ||
$(COMPOSE) up -d $(DAEMONS) | ||
$(DRUN) ./configure.sh $(CHANNEL_NAME) "$(CHANNEL_TXNS)" "$(PEERS)" $(TLS) | ||
@./compose/report-env.sh "$(DAEMONS)" build/client.config $(TLS) | ||
|
||
compose-down: | ||
$(COMPOSE) down | ||
rm -rf build/nodes $(CRYPTOOUTPUT) | ||
compose: nodes build/docker-compose.yaml build/compose-up.sh build/configure.sh | ||
@echo "Build complete: run 'build/compose-up.sh'" | ||
|
||
nodes: $(patsubst %,build/nodes/%,$(NODES)) | ||
|
||
|
@@ -117,6 +110,29 @@ build/nodes/tlsca: build/nodes/tlsca/fabric-tlsca-server-config.yaml | |
build/nodes/%: build/nodes/%/msp build/nodes/%/configtx.yaml build/nodes/%/core.yaml | ||
@echo "Built $@" | ||
|
||
clean: compose-down | ||
rm -rf build | ||
rm $(CHANNEL_NAME).block | ||
build/docker-compose.yaml: compose/docker-compose.yaml.in | ||
@mkdir -p $(@D) | ||
cat $< \ | ||
| sed -e 's/_TLS_ENABLED_/${TLS}/g' \ | ||
| sed -e 's/_DOCKER_NS_/${DOCKER_NS}/g' \ | ||
| sed -e 's/_CA_RELEASE_/${CA_RELEASE}/g' \ | ||
| sed -e 's/_FABRIC_RELEASE_/${FABRIC_RELEASE}/g' \ | ||
> $@ | ||
|
||
build/compose-up.sh: compose/compose-up.sh.in | ||
@mkdir -p $(@D) | ||
cat $< \ | ||
| sed -e 's/_COMPOSE_DAEMONS_/${DAEMONS}/g' \ | ||
| sed -e 's/_COMPOSE_CHANNEL_NAME_/${CHANNEL_NAME}/g' \ | ||
| sed -e 's/_COMPOSE_PEERS_/${PEERS}/g' \ | ||
| sed -e 's/_COMPOSE_NODES_/${NODES}/g' \ | ||
| sed -e 's/_COMPOSE_TLS_/${TLS}/g' \ | ||
> $@ | ||
chmod +x $@ | ||
|
||
build/configure.sh: compose/configure.sh.in | ||
cp $< $@ | ||
|
||
clean: | ||
-rm -rf build | ||
-rm $(CHANNEL_NAME).block |
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 |
---|---|---|
|
@@ -5,10 +5,16 @@ | |
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
set -e | ||
|
||
NODES=$1 | ||
CONFIG=$2 | ||
TLS=$3 | ||
DAEMONS="_COMPOSE_DAEMONS_" | ||
CHANNEL_NAME=_COMPOSE_CHANNEL_NAME_ | ||
PEERS="_COMPOSE_PEERS_" | ||
NODES="_COMPOSE_NODES_" | ||
TLS=_COMPOSE_TLS_ | ||
|
||
SCRIPTDIR=`dirname $0` | ||
OUTPUT=${1:-$SCRIPTDIR/client.config} | ||
|
||
getip() { | ||
HOST=$1 | ||
|
@@ -49,7 +55,7 @@ peerurls() { | |
} | ||
|
||
generate_hosts() { | ||
for NODE in $NODES; do | ||
for NODE in $DAEMONS; do | ||
echo "$(getip $NODE) $NODE" | ||
done | ||
} | ||
|
@@ -65,28 +71,38 @@ includefile() { | |
done < "$file" | ||
} | ||
|
||
echo "========================================================================" | ||
echo "Launching Hyperledger Cluster via docker-compose" | ||
echo "========================================================================" | ||
docker-compose -f $SCRIPTDIR/docker-compose.yaml up -d $DAEMONS | ||
|
||
echo "========================================================================" | ||
echo "Configuring cluster" | ||
echo "========================================================================" | ||
(cd $SCRIPTDIR && docker-compose run --rm cli ./configure.sh $CHANNEL_NAME "channel.tx anchor.tx" "$PEERS" $TLS) | ||
|
||
echo "========================================================================" | ||
echo "Cluster ready!" | ||
echo "========================================================================" | ||
echo | ||
generate_hosts | sort | ||
|
||
cat <<EOF > $CONFIG | ||
cat <<EOF > $OUTPUT | ||
# | ||
# Generated by fabric.git/examples/cluster. DO NOT EDIT! | ||
# | ||
ca: | ||
url: $(http "ca" "7054") | ||
certificate: $(includefile build/nodes/ca/ca.crt " ") | ||
certificate: $(includefile $SCRIPTDIR/nodes/ca/ca.crt " ") | ||
tlsca: | ||
url: $(http "tlsca" "7054") | ||
certificate: $(includefile build/nodes/tlsca/ca.crt " ") | ||
certificate: $(includefile $SCRIPTDIR/nodes/tlsca/ca.crt " ") | ||
orderer: | ||
url: $(grpc "orderer" "7050") | ||
hostname: orderer | ||
ca: $(includefile build/nodes/orderer/tls/ca.crt " ") | ||
ca: $(includefile $SCRIPTDIR/nodes/orderer/tls/ca.crt " ") | ||
peers: | ||
$(for i in $(seq 1 4); do | ||
|
@@ -98,6 +114,8 @@ done) | |
identity: | ||
principal: [email protected] | ||
mspid: Org1MSP | ||
privatekey: $(includefile build/nodes/cli/tls/server.key " ") | ||
certificate: $(includefile build/nodes/cli/tls/server.crt " ") | ||
privatekey: $(includefile $SCRIPTDIR/nodes/cli/tls/server.key " ") | ||
certificate: $(includefile $SCRIPTDIR/nodes/cli/tls/server.crt " ") | ||
EOF | ||
|
||
echo "Output written to $OUTPUT" |
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 was deleted.
Oops, something went wrong.
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