├── .env ├── .gitignore ├── README.md ├── bin ├── configtxgen ├── configtxlator ├── cryptogen ├── fabric-ca-client ├── get-docker-images.sh ├── orderer └── peer ├── chaincode └── sacc.go ├── generate.sh ├── install.sh ├── network-config ├── configtx.yaml ├── crypto-config.yaml ├── docker-compose-base.yml ├── docker-compose-cli.yml ├── docker-compose-couchdb.yml └── docker-compose-kafka.yml ├── start.sh ├── stop.sh ├── teardown.sh ├── test.sh └── update.sh /.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=net 2 | CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=10 3 | CONFIGTX_ORDERER_BATCHTIMEOUT=2s 4 | KAFKA_DEFAULT_REPLICATION_FACTOR=3 5 | CORE_LOGGING_GOSSIP=WARNING 6 | ORDERER_GENERAL_TLS_ENABLED=false 7 | ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/tls/server.key 8 | ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/tls/server.crt 9 | ORDERER_TLS_CLIENTAUTHREQUIRED=false 10 | CORE_PEER_TLS_ENABLED=false 11 | CORE_PEER_TLS_CERT_FILE=/var/hyperledger/tls/server.crt 12 | CORE_PEER_TLS_KEY_FILE=/var/hyperledger/tls/server.key 13 | CORE_PEER_TLS_CLIENTAUTHREQUIRED=false 14 | CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG1=false 15 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG1=true 16 | CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG2=false 17 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG2=true 18 | CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG3=false 19 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG3=true 20 | CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG1=false 21 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG1=true 22 | CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG2=false 23 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG2=true 24 | CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG3=false 25 | CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG3=true 26 | ORDERER_ABSOLUTEMAXBYTES=10 MB 27 | ORDERER_PREFERREDMAXBYTES=512 KB 28 | KAFKA_MESSAGE_MAX_BYTES=1000012 B 29 | KAFKA_REPLICA_FETCH_MAX_BYTES=1048576 B 30 | KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=10485760 B 31 | CORE_PEER_NETWORKID=net -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config/ 2 | crypto-config/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kafka Fabric Network 2 | 3 | This repository holds the configuration and the sample chaincode for testing a kafka enabled network. 4 | 5 | ## Introduction 6 | 7 | The Hyperledger Fabric has introduced Kafka as it’s primary consensus mechanism among the orderers. While in development, for testing purposes, a solo config orderer is used. However, in production, you need to have multiple orderer nodes set up to have fail proof systems. In the case of a hardware/software failure, this is what will rescue you from critical situations. Kafka helps implement this easily. To understand in detail how all of this works, refer to this article [TODO]. 8 | 9 | 10 | ## Assumptions 11 | 12 | You already know how to work with Hyperledger Fabric and deploy chaincode to the network in development. You are also comfortable with docker and docker-compose. To get comfortable with these topics, refer to these [articles](https://www.skcript.com/svr/blockchain/). 13 | 14 | 15 | ## Network Architecture 16 | 17 | We have a simple network configuration 18 | 19 | - 3 Orderers. 20 | - 2 Organizations. 21 | - 4 peers, 2 for each organization. 22 | - 4 Kafka broker instances. 23 | - 3 Zookeper instances. 24 | 25 | ## Technical Documentation 26 | 27 | ### Folder Structure 28 | ``` 29 | ./ 30 | ├── bin 31 | │   ├── configtxgen 32 | │   ├── configtxlator 33 | │   ├── cryptogen 34 | │   ├── fabric-ca-client 35 | │   ├── get-docker-images.sh 36 | │   ├── orderer 37 | │   └── peer 38 | ├── chaincode 39 | │   └── sacc.go 40 | ├── network-config 41 | │   ├── configtx.yaml 42 | │   ├── crypto-config.yaml 43 | │   ├── docker-compose-base.yml 44 | │   ├── docker-compose-cli.yml 45 | │   ├── docker-compose-couchdb.yml 46 | │   ├── docker-compose-kafka.yml 47 | │   ├── docker-compose-peer-org3.yml 48 | │   └── docker-compose-solo.yml 49 | ├── generate.sh 50 | ├── install.sh 51 | ├── README.md 52 | ├── start.sh 53 | ├── stop.sh 54 | ├── teardown.sh 55 | ├── test.sh 56 | └── update.sh 57 | 58 | 3 directories, 24 files 59 | ``` 60 | ### Description 61 | 62 | - `bin/` contains all the binaries required for generating crypto material. 63 | - `chaincode/` contains the sacc chaincode, present in `fabric-samples`. 64 | - `network-config/` contains all the configuration `yaml` files for the network. 65 | - `generate.sh` will generate all the crypto-material required for the network to run. 66 | - `install.sh` will install and instantiate the chaincode. 67 | - `start.sh` will start all the containers in docker-compose files. 68 | - `stop.sh` will stop and remove all docker containers, use with caution. 69 | - `teardown.sh` will kill containers and remove images generated by the network. 70 | - `test.sh` is used to test an invoke query. 71 | - `update.sh` is used to install and upgrade chaincode. 72 | 73 | ### Steps 74 | 75 | - Make sure you've grabbed all the [prerequisites](http://hyperledger-fabric.readthedocs.io/en/release-1.1/prereqs.html) and [samples](http://hyperledger-fabric.readthedocs.io/en/release-1.1/samples.html#) for running hyperledger fabric. 76 | - In your `$GOPATH`, make sure you have the hyperledger fabric source. 77 | ```bash 78 | cd $GOPATH/src/github.com/ 79 | mkdir hyperledger 80 | cd hyperledger 81 | git clone https://github.com/hyperledger/fabric.git 82 | ``` 83 | - Clone this repository and enter the directory. 84 | ```bash 85 | git clone https://github.com/Presto412/Kafka-Fabric-Network.git 86 | cd Kafka-Fabric-Network 87 | ``` 88 | NOTE : Give exec permissions to the shell scripts 89 | ```chmod 777 ./script-name.sh``` 90 | - Generate the crypto-material 91 | ```bash 92 | ./generate.sh 93 | ``` 94 | - Start the network 95 | ```bash 96 | ./start.sh 97 | ``` 98 | - Install and Instantiate the chaincode 99 | ```bash 100 | ./install.sh 101 | ``` 102 | - Verify if all the docker containers are running 103 | ```bash 104 | docker ps 105 | ``` 106 | - Test a sample invoke command 107 | ```bash 108 | ./test.sh 109 | ``` 110 | - Stop every docker container and kill all the containers 111 | ```bash 112 | ./stop.sh 113 | ``` -------------------------------------------------------------------------------- /bin/configtxgen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/configtxgen -------------------------------------------------------------------------------- /bin/configtxlator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/configtxlator -------------------------------------------------------------------------------- /bin/cryptogen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/cryptogen -------------------------------------------------------------------------------- /bin/fabric-ca-client: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/fabric-ca-client -------------------------------------------------------------------------------- /bin/get-docker-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # Copyright London Stock Exchange Group All Rights Reserved. 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 5 | # 6 | # This script pulls docker images from the Dockerhub hyperledger repositories 7 | 8 | # set the default Docker namespace and tag 9 | DOCKER_NS=hyperledger 10 | ARCH=x86_64 11 | VERSION=1.1.0 12 | BASE_DOCKER_TAG=x86_64-0.4.6 13 | 14 | # set of Hyperledger Fabric images 15 | FABRIC_IMAGES=(fabric-peer fabric-orderer fabric-ccenv fabric-javaenv fabric-kafka fabric-zookeeper \ 16 | fabric-couchdb fabric-tools) 17 | 18 | for image in ${FABRIC_IMAGES[@]}; do 19 | echo "Pulling ${DOCKER_NS}/$image:${ARCH}-${VERSION}" 20 | docker pull ${DOCKER_NS}/$image:${ARCH}-${VERSION} 21 | done 22 | 23 | echo "Pulling ${DOCKER_NS}/fabric-baseos:${BASE_DOCKER_TAG}" 24 | docker pull ${DOCKER_NS}/fabric-baseos:${BASE_DOCKER_TAG} 25 | -------------------------------------------------------------------------------- /bin/orderer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/orderer -------------------------------------------------------------------------------- /bin/peer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skcript/hlf-kafka-network/0d1efa77ace5eac6bbc3195777188d9d0b1850d9/bin/peer -------------------------------------------------------------------------------- /chaincode/sacc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright IBM Corp All Rights Reserved 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | 12 | "github.com/hyperledger/fabric/core/chaincode/shim" 13 | "github.com/hyperledger/fabric/protos/peer" 14 | ) 15 | 16 | // SimpleAsset implements a simple chaincode to manage an asset 17 | type SimpleAsset struct { 18 | } 19 | 20 | // Init is called during chaincode instantiation to initialize any 21 | // data. Note that chaincode upgrade also calls this function to reset 22 | // or to migrate data. 23 | func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response { 24 | // Get the args from the transaction proposal 25 | args := stub.GetStringArgs() 26 | if len(args) != 2 { 27 | return shim.Error("Incorrect arguments. Expecting a key and a value") 28 | } 29 | 30 | // Set up any variables or assets here by calling stub.PutState() 31 | 32 | // We store the key and the value on the ledger 33 | err := stub.PutState(args[0], []byte(args[1])) 34 | if err != nil { 35 | return shim.Error(fmt.Sprintf("Failed to create asset: %s", args[0])) 36 | } 37 | return shim.Success(nil) 38 | } 39 | 40 | // Invoke is called per transaction on the chaincode. Each transaction is 41 | // either a 'get' or a 'set' on the asset created by Init function. The Set 42 | // method may create a new asset by specifying a new key-value pair. 43 | func (t *SimpleAsset) Invoke(stub shim.ChaincodeStubInterface) peer.Response { 44 | // Extract the function and args from the transaction proposal 45 | fn, args := stub.GetFunctionAndParameters() 46 | 47 | var result string 48 | var err error 49 | if fn == "set" { 50 | result, err = set(stub, args) 51 | } else { // assume 'get' even if fn is nil 52 | result, err = get(stub, args) 53 | } 54 | if err != nil { 55 | return shim.Error(err.Error()) 56 | } 57 | 58 | // Return the result as success payload 59 | return shim.Success([]byte(result)) 60 | } 61 | 62 | // Set stores the asset (both key and value) on the ledger. If the key exists, 63 | // it will override the value with the new one 64 | func set(stub shim.ChaincodeStubInterface, args []string) (string, error) { 65 | if len(args) != 2 { 66 | return "", fmt.Errorf("Incorrect arguments. Expecting a key and a value") 67 | } 68 | 69 | err := stub.PutState(args[0], []byte(args[1])) 70 | if err != nil { 71 | return "", fmt.Errorf("Failed to set asset: %s", args[0]) 72 | } 73 | return args[1], nil 74 | } 75 | 76 | // Get returns the value of the specified asset key 77 | func get(stub shim.ChaincodeStubInterface, args []string) (string, error) { 78 | if len(args) != 1 { 79 | return "", fmt.Errorf("Incorrect arguments. Expecting a key") 80 | } 81 | 82 | value, err := stub.GetState(args[0]) 83 | if err != nil { 84 | return "", fmt.Errorf("Failed to get asset: %s with error: %s", args[0], err) 85 | } 86 | if value == nil { 87 | return "", fmt.Errorf("Asset not found: %s", args[0]) 88 | } 89 | return string(value), nil 90 | } 91 | 92 | // main function starts up the chaincode in the container during instantiate 93 | func main() { 94 | if err := shim.Start(new(SimpleAsset)); err != nil { 95 | fmt.Printf("Error starting SimpleAsset chaincode: %s", err) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright IBM Corp All Rights Reserved 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | export PATH=$GOPATH/src/github.com/hyperledger/fabric/build/bin:${PWD}/bin:${PWD}:$PATH 8 | export FABRIC_CFG_PATH=${PWD}/network-config 9 | CHANNEL_NAME=mychannel 10 | 11 | # create folders 12 | mkdir -p config 13 | mkdir -p crypto-config 14 | 15 | # remove previous crypto material and config transactions 16 | rm -fr ./config/* 17 | rm -fr ./crypto-config/* 18 | 19 | 20 | # generate crypto material 21 | cryptogen generate --config=./network-config/crypto-config.yaml 22 | if [ "$?" -ne 0 ]; then 23 | echo "Failed to generate crypto material..." 24 | exit 1 25 | fi 26 | 27 | # generate genesis block for orderer 28 | configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./config/orderer.block 29 | if [ "$?" -ne 0 ]; then 30 | echo "Failed to generate orderer genesis block..." 31 | exit 1 32 | fi 33 | 34 | # generate channel configuration transaction 35 | configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./config/channel.tx -channelID $CHANNEL_NAME 36 | if [ "$?" -ne 0 ]; then 37 | echo "Failed to generate channel configuration transaction..." 38 | exit 1 39 | fi 40 | 41 | # generate anchor peer transaction 42 | configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./config/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP 43 | if [ "$?" -ne 0 ]; then 44 | echo "Failed to generate anchor peer update for Org1MSP..." 45 | exit 1 46 | fi 47 | 48 | # generate anchor peer transaction 49 | configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./config/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP 50 | if [ "$?" -ne 0 ]; then 51 | echo "Failed to generate anchor peer update for Org2MSP..." 52 | exit 1 53 | fi 54 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | # to be executed on start 2 | docker exec -it cli peer chaincode install -n mycc -p github.com/chaincode -v v0 3 | docker exec -it cli peer chaincode instantiate -o orderer0.example.com:7050 -C mychannel -n mycc github.com/chaincode -v v0 -c '{"Args": ["a", "100"]}' -------------------------------------------------------------------------------- /network-config/configtx.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | Profiles: 3 | 4 | TwoOrgsOrdererGenesis: 5 | Orderer: 6 | <<: *OrdererDefaults 7 | Organizations: 8 | - *OrdererOrg 9 | Consortiums: 10 | SampleConsortium: 11 | Organizations: 12 | - *Org1 13 | - *Org2 14 | TwoOrgsChannel: 15 | Consortium: SampleConsortium 16 | Application: 17 | <<: *ApplicationDefaults 18 | Organizations: 19 | - *Org1 20 | - *Org2 21 | Organizations: 22 | 23 | - &OrdererOrg 24 | Name: OrdererOrg 25 | ID: OrdererMSP 26 | MSPDir: ../crypto-config/ordererOrganizations/example.com/msp 27 | 28 | - &Org1 29 | Name: Org1MSP 30 | ID: Org1MSP 31 | MSPDir: ../crypto-config/peerOrganizations/org1.example.com/msp 32 | AnchorPeers: 33 | - Host: peer0.org1.example.com 34 | Port: 7051 35 | 36 | - &Org2 37 | Name: Org2MSP 38 | ID: Org2MSP 39 | MSPDir: ../crypto-config/peerOrganizations/org2.example.com/msp 40 | AnchorPeers: 41 | - Host: peer0.org2.example.com 42 | Port: 7051 43 | 44 | Orderer: &OrdererDefaults 45 | 46 | OrdererType: kafka 47 | Addresses: 48 | - orderer0.example.com:7050 49 | - orderer1.example.com:7050 50 | - orderer2.example.com:7050 51 | BatchTimeout: 2s 52 | BatchSize: 53 | MaxMessageCount: 10 54 | AbsoluteMaxBytes: 99 MB 55 | PreferredMaxBytes: 512 KB 56 | Kafka: 57 | Brokers: 58 | - kafka0:9092 59 | - kafka1:9092 60 | - kafka2:9092 61 | - kafka3:9092 62 | Organizations: 63 | Application: &ApplicationDefaults 64 | Organizations: 65 | -------------------------------------------------------------------------------- /network-config/crypto-config.yaml: -------------------------------------------------------------------------------- 1 | 2 | OrdererOrgs: 3 | - Name: Orderer 4 | Domain: example.com 5 | Template: 6 | Count: 3 7 | PeerOrgs: 8 | - Name: Org1 9 | Domain: org1.example.com 10 | Template: 11 | Count: 2 12 | Users: 13 | Count: 1 14 | - Name: Org2 15 | Domain: org2.example.com 16 | Template: 17 | Count: 2 18 | Users: 19 | Count: 1 20 | -------------------------------------------------------------------------------- /network-config/docker-compose-base.yml: -------------------------------------------------------------------------------- 1 | 2 | version: '2' 3 | 4 | services: 5 | 6 | zookeeper: 7 | image: hyperledger/fabric-zookeeper 8 | ports: 9 | - 2181 10 | - 2888 11 | - 3888 12 | 13 | kafka: 14 | image: hyperledger/fabric-kafka 15 | environment: 16 | - KAFKA_LOG_RETENTION_MS=-1 17 | - KAFKA_MESSAGE_MAX_BYTES=103809024 18 | - KAFKA_REPLICA_FETCH_MAX_BYTES=103809024 19 | - KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false 20 | - KAFKA_DEFAULT_REPLICATION_FACTOR=${KAFKA_DEFAULT_REPLICATION_FACTOR} 21 | - KAFKA_MIN_INSYNC_REPLICAS=2 22 | ports: 23 | - 9092 24 | 25 | orderer: 26 | image: hyperledger/fabric-orderer 27 | environment: 28 | - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${CORE_PEER_NETWORKID}_behave 29 | - ORDERER_HOME=/var/hyperledger/orderer 30 | - ORDERER_GENERAL_LOGLEVEL=debug 31 | - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/msp 32 | - ORDERER_GENERAL_LOCALMSPID=OrdererMSP 33 | - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 34 | - ORDERER_GENERAL_LISTENPORT=7050 35 | - ORDERER_GENERAL_LEDGERTYPE=ram 36 | - ORDERER_GENERAL_GENESISMETHOD=file 37 | - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/configs/orderer.block 38 | - CONFIGTX_ORDERER_ORDERERTYPE=solo 39 | - CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=${CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT} 40 | - CONFIGTX_ORDERER_BATCHTIMEOUT=${CONFIGTX_ORDERER_BATCHTIMEOUT} 41 | - CONFIGTX_ORDERER_ADDRESSES=[127.0.0.1:7050] 42 | # TLS settings 43 | - ORDERER_GENERAL_TLS_ENABLED=${ORDERER_GENERAL_TLS_ENABLED} 44 | - ORDERER_GENERAL_TLS_PRIVATEKEY=${ORDERER_GENERAL_TLS_PRIVATEKEY} 45 | - ORDERER_GENERAL_TLS_CERTIFICATE=${ORDERER_GENERAL_TLS_CERTIFICATE} 46 | - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/tls/ca.crt] 47 | - ORDERER_TLS_CLIENTAUTHREQUIRED=${ORDERER_TLS_CLIENTAUTHREQUIRED} 48 | - ORDERER_TLS_CLIENTROOTCAS_FILES=/var/hyperledger/users/Admin@example.com/tls/ca.crt 49 | - ORDERER_TLS_CLIENTCERT_FILE=/var/hyperledger/users/Admin@example.com/tls/client.crt 50 | - ORDERER_TLS_CLIENTKEY_FILE=/var/hyperledger/users/Admin@example.com/tls/client.key 51 | volumes: 52 | - ../config/:/var/hyperledger/configs 53 | - ../crypto-config/ordererOrganizations/example.com/users:/var/hyperledger/users 54 | working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer 55 | command: orderer 56 | ports: 57 | - '7050' 58 | 59 | couchdb: 60 | image: hyperledger/fabric-couchdb 61 | 62 | peer: 63 | image: hyperledger/fabric-peer 64 | environment: 65 | - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 66 | - CORE_PEER_NETWORKID=${CORE_PEER_NETWORKID} 67 | - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${CORE_PEER_NETWORKID}_behave 68 | - CORE_PEER_ADDRESSAUTODETECT=true 69 | - CORE_PEER_GOSSIP_ORGLEADER=false 70 | - CORE_PEER_GOSSIP_USELEADERELECTION=true 71 | - CORE_PEER_PROFILE_ENABLED=true 72 | - CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp 73 | #- CORE_LEDGER_STATE_STATEDATABASE=LevelDB 74 | - CORE_LOGGING_LEVEL=DEBUG 75 | - CORE_LOGGING_GOSSIP=${CORE_LOGGING_GOSSIP} 76 | - CORE_LOGGING_MSP=DEBUG 77 | # TLS settings 78 | - CORE_PEER_TLS_ENABLED=${CORE_PEER_TLS_ENABLED} 79 | - CORE_PEER_TLS_CLIENTAUTHREQUIRED=${CORE_PEER_TLS_CLIENTAUTHREQUIRED} 80 | - CORE_PEER_TLS_CERT_FILE=${CORE_PEER_TLS_CERT_FILE} 81 | - CORE_PEER_TLS_KEY_FILE=${CORE_PEER_TLS_KEY_FILE} 82 | - CORE_PEER_TLS_ROOTCERT_FILE=/var/hyperledger/tls/ca.crt 83 | volumes: 84 | - /var/run/:/host/var/run/ 85 | - $GOPATH/src/github.com/hyperledger/fabric/:/opt/gopath/src/github.com/hyperledger/fabric/ 86 | - ../crypto-config/:/var/hyperledger/configs 87 | - ../config/:/var/hyperledger/configs 88 | command: peer node start 89 | ports: 90 | - '7051' 91 | - '7053' 92 | 93 | -------------------------------------------------------------------------------- /network-config/docker-compose-cli.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | networks: 4 | behave: 5 | 6 | services: 7 | cli: 8 | container_name: cli 9 | image: hyperledger/fabric-tools 10 | tty: true 11 | environment: 12 | - GOPATH=/opt/gopath 13 | - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 14 | - CORE_LOGGING_LEVEL=DEBUG 15 | - CORE_PEER_ID=cli 16 | - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 17 | - CORE_PEER_LOCALMSPID=Org1MSP 18 | - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 19 | - CORE_CHAINCODE_KEEPALIVE=10 20 | working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer 21 | command: /bin/bash 22 | volumes: 23 | - /var/run/:/host/var/run/ 24 | - ../chaincode/:/opt/gopath/src/github.com/chaincode 25 | - $GOPATH/src/github.com/hyperledger/fabric/:/opt/gopath/src/github.com/hyperledger/fabric/ 26 | - ../crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ 27 | networks: 28 | - behave -------------------------------------------------------------------------------- /network-config/docker-compose-couchdb.yml: -------------------------------------------------------------------------------- 1 | 2 | version: '2' 3 | 4 | networks: 5 | behave: 6 | 7 | 8 | services: 9 | couchdb01: 10 | extends: 11 | file: docker-compose-base.yml 12 | service: couchdb 13 | container_name: couchdb01 14 | # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, 15 | # for example map it to utilize Fauxton User Interface in dev environments. 16 | ports: 17 | - "5984:5984" 18 | networks: 19 | behave: 20 | aliases: 21 | - ${CORE_PEER_NETWORKID} 22 | 23 | peer0.org1.example.com: 24 | environment: 25 | - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 26 | - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb01:5984 27 | depends_on: 28 | - orderer0.example.com 29 | - couchdb01 30 | 31 | couchdb02: 32 | extends: 33 | file: docker-compose-base.yml 34 | service: couchdb 35 | container_name: couchdb02 36 | # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, 37 | # for example map it to utilize Fauxton User Interface in dev environments. 38 | ports: 39 | - "6984:5984" 40 | networks: 41 | behave: 42 | aliases: 43 | - ${CORE_PEER_NETWORKID} 44 | 45 | peer0.org2.example.com: 46 | environment: 47 | - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 48 | - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb02:5984 49 | depends_on: 50 | - orderer0.example.com 51 | - couchdb02 52 | 53 | couchdb11: 54 | extends: 55 | file: docker-compose-base.yml 56 | service: couchdb 57 | container_name: couchdb11 58 | # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, 59 | # for example map it to utilize Fauxton User Interface in dev environments. 60 | ports: 61 | - "7984:5984" 62 | networks: 63 | behave: 64 | aliases: 65 | - ${CORE_PEER_NETWORKID} 66 | 67 | peer1.org1.example.com: 68 | environment: 69 | - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 70 | - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb11:5984 71 | depends_on: 72 | - orderer0.example.com 73 | - couchdb11 74 | 75 | couchdb12: 76 | extends: 77 | file: docker-compose-base.yml 78 | service: couchdb 79 | container_name: couchdb12 80 | # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, 81 | # for example map it to utilize Fauxton User Interface in dev environments. 82 | ports: 83 | - "8984:5984" 84 | networks: 85 | behave: 86 | aliases: 87 | - ${CORE_PEER_NETWORKID} 88 | 89 | peer1.org2.example.com: 90 | environment: 91 | - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 92 | - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb12:5984 93 | depends_on: 94 | - orderer0.example.com 95 | - couchdb12 96 | -------------------------------------------------------------------------------- /network-config/docker-compose-kafka.yml: -------------------------------------------------------------------------------- 1 | 2 | version: '2' 3 | 4 | networks: 5 | behave: 6 | 7 | services: 8 | 9 | zookeeper0: 10 | extends: 11 | file: docker-compose-base.yml 12 | service: zookeeper 13 | container_name: zookeeper0 14 | environment: 15 | - ZOO_MY_ID=1 16 | - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2888:3888 server.3=zookeeper2:2888:3888 17 | networks: 18 | behave: 19 | aliases: 20 | - ${CORE_PEER_NETWORKID} 21 | 22 | zookeeper1: 23 | extends: 24 | file: docker-compose-base.yml 25 | service: zookeeper 26 | container_name: zookeeper1 27 | environment: 28 | - ZOO_MY_ID=2 29 | - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2888:3888 server.3=zookeeper2:2888:3888 30 | networks: 31 | behave: 32 | aliases: 33 | - ${CORE_PEER_NETWORKID} 34 | 35 | zookeeper2: 36 | extends: 37 | file: docker-compose-base.yml 38 | service: zookeeper 39 | container_name: zookeeper2 40 | environment: 41 | - ZOO_MY_ID=3 42 | - ZOO_SERVERS=server.1=zookeeper0:2888:3888 server.2=zookeeper1:2888:3888 server.3=zookeeper2:2888:3888 43 | networks: 44 | behave: 45 | aliases: 46 | - ${CORE_PEER_NETWORKID} 47 | 48 | kafka0: 49 | extends: 50 | file: docker-compose-base.yml 51 | service: kafka 52 | container_name: kafka0 53 | environment: 54 | - KAFKA_BROKER_ID=0 55 | - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2181,zookeeper2:2181 56 | - KAFKA_MESSAGE_MAX_BYTES=${KAFKA_MESSAGE_MAX_BYTES} 57 | - KAFKA_REPLICA_FETCH_MAX_BYTES=${KAFKA_REPLICA_FETCH_MAX_BYTES} 58 | - KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=${KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES} 59 | depends_on: 60 | - zookeeper0 61 | - zookeeper1 62 | - zookeeper2 63 | networks: 64 | behave: 65 | aliases: 66 | - ${CORE_PEER_NETWORKID} 67 | 68 | kafka1: 69 | extends: 70 | file: docker-compose-base.yml 71 | service: kafka 72 | container_name: kafka1 73 | environment: 74 | - KAFKA_BROKER_ID=1 75 | - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2181,zookeeper2:2181 76 | - KAFKA_MESSAGE_MAX_BYTES=${KAFKA_MESSAGE_MAX_BYTES} 77 | - KAFKA_REPLICA_FETCH_MAX_BYTES=${KAFKA_REPLICA_FETCH_MAX_BYTES} 78 | - KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=${KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES} 79 | depends_on: 80 | - zookeeper0 81 | - zookeeper1 82 | - zookeeper2 83 | networks: 84 | behave: 85 | aliases: 86 | - ${CORE_PEER_NETWORKID} 87 | 88 | kafka2: 89 | extends: 90 | file: docker-compose-base.yml 91 | service: kafka 92 | container_name: kafka2 93 | environment: 94 | - KAFKA_BROKER_ID=2 95 | - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2181,zookeeper2:2181 96 | - KAFKA_MESSAGE_MAX_BYTES=${KAFKA_MESSAGE_MAX_BYTES} 97 | - KAFKA_REPLICA_FETCH_MAX_BYTES=${KAFKA_REPLICA_FETCH_MAX_BYTES} 98 | - KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=${KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES} 99 | depends_on: 100 | - zookeeper0 101 | - zookeeper1 102 | - zookeeper2 103 | networks: 104 | behave: 105 | aliases: 106 | - ${CORE_PEER_NETWORKID} 107 | 108 | kafka3: 109 | extends: 110 | file: docker-compose-base.yml 111 | service: kafka 112 | container_name: kafka3 113 | environment: 114 | - KAFKA_BROKER_ID=3 115 | - KAFKA_ZOOKEEPER_CONNECT=zookeeper0:2181,zookeeper1:2181,zookeeper2:2181 116 | - KAFKA_MESSAGE_MAX_BYTES=${KAFKA_MESSAGE_MAX_BYTES} 117 | - KAFKA_REPLICA_FETCH_MAX_BYTES=${KAFKA_REPLICA_FETCH_MAX_BYTES} 118 | - KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES=${KAFKA_REPLICA_FETCH_RESPONSE_MAX_BYTES} 119 | depends_on: 120 | - zookeeper0 121 | - zookeeper1 122 | - zookeeper2 123 | networks: 124 | behave: 125 | aliases: 126 | - ${CORE_PEER_NETWORKID} 127 | 128 | orderer0.example.com: 129 | extends: 130 | file: docker-compose-base.yml 131 | service: orderer 132 | container_name: orderer0.example.com 133 | environment: 134 | - ORDERER_HOST=orderer0.example.com 135 | - CONFIGTX_ORDERER_ORDERERTYPE=kafka 136 | - CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092,kafka3:9092] 137 | - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s 138 | - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s 139 | - ORDERER_KAFKA_VERBOSE=true 140 | - ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka 141 | - ORDERER_ABSOLUTEMAXBYTES=${ORDERER_ABSOLUTEMAXBYTES} 142 | - ORDERER_PREFERREDMAXBYTES=${ORDERER_PREFERREDMAXBYTES} 143 | volumes: 144 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp:/var/hyperledger/msp 145 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/tls:/var/hyperledger/tls 146 | - ../config/:/var/hyperledger/configs 147 | depends_on: 148 | - kafka0 149 | - kafka1 150 | - kafka2 151 | - kafka3 152 | networks: 153 | behave: 154 | aliases: 155 | - ${CORE_PEER_NETWORKID} 156 | ports: 157 | - 7050:7050 158 | 159 | orderer1.example.com: 160 | extends: 161 | file: docker-compose-base.yml 162 | service: orderer 163 | container_name: orderer1.example.com 164 | environment: 165 | - ORDERER_HOST=orderer1.example.com 166 | - CONFIGTX_ORDERER_ORDERERTYPE=kafka 167 | - CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092,kafka3:9092] 168 | - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s 169 | - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s 170 | - ORDERER_KAFKA_RETRY_LONGINTERVAL=30s 171 | - ORDERER_KAFKA_RETRY_LONGTOTAL=5m 172 | - ORDERER_KAFKA_VERBOSE=true 173 | - ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka 174 | - ORDERER_ABSOLUTEMAXBYTES=${ORDERER_ABSOLUTEMAXBYTES} 175 | - ORDERER_PREFERREDMAXBYTES=${ORDERER_PREFERREDMAXBYTES} 176 | volumes: 177 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp:/var/hyperledger/msp 178 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/tls:/var/hyperledger/tls 179 | - ../config/:/var/hyperledger/configs 180 | depends_on: 181 | - kafka0 182 | - kafka1 183 | - kafka2 184 | - kafka3 185 | networks: 186 | behave: 187 | aliases: 188 | - ${CORE_PEER_NETWORKID} 189 | ports: 190 | - 8050:7050 191 | 192 | orderer2.example.com: 193 | extends: 194 | file: docker-compose-base.yml 195 | service: orderer 196 | container_name: orderer2.example.com 197 | environment: 198 | - ORDERER_HOST=orderer2.example.com 199 | - CONFIGTX_ORDERER_ORDERERTYPE=kafka 200 | - CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092,kafka3:9092] 201 | - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s 202 | - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s 203 | - ORDERER_KAFKA_VERBOSE=true 204 | - ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka 205 | - ORDERER_ABSOLUTEMAXBYTES=${ORDERER_ABSOLUTEMAXBYTES} 206 | - ORDERER_PREFERREDMAXBYTES=${ORDERER_PREFERREDMAXBYTES} 207 | volumes: 208 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp:/var/hyperledger/msp 209 | - ../crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls:/var/hyperledger/tls 210 | - ../config/:/var/hyperledger/configs 211 | depends_on: 212 | - kafka0 213 | - kafka1 214 | - kafka2 215 | - kafka3 216 | networks: 217 | behave: 218 | aliases: 219 | - ${CORE_PEER_NETWORKID} 220 | ports: 221 | - 9050:7050 222 | 223 | peer0.org1.example.com: 224 | extends: 225 | file: docker-compose-base.yml 226 | service: peer 227 | container_name: peer0.org1.example.com 228 | environment: 229 | - CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052 230 | - CORE_PEER_ID=peer0.org1.example.com 231 | - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 232 | - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7051 233 | - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 234 | - CORE_PEER_GOSSIP_ORGLEADER=${CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG1} 235 | - CORE_PEER_GOSSIP_USELEADERELECTION=${CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG1} 236 | - CORE_PEER_LOCALMSPID=Org1MSP 237 | - CORE_PEER_TLS_CLIENTROOTCAS_FILES=/var/hyperledger/users/Admin@org1.example.com/tls/ca.crt 238 | - CORE_PEER_TLS_CLIENTCERT_FILE=/var/hyperledger/users/Admin@org1.example.com/tls/client.crt 239 | - CORE_PEER_TLS_CLIENTKEY_FILE=/var/hyperledger/users/Admin@org1.example.com/tls/client.key 240 | volumes: 241 | - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/var/hyperledger/msp 242 | - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/var/hyperledger/tls 243 | - ../crypto-config/peerOrganizations/org1.example.com/users:/var/hyperledger/users 244 | - ../config/:/var/hyperledger/configs 245 | 246 | depends_on: 247 | - orderer0.example.com 248 | - orderer1.example.com 249 | - orderer2.example.com 250 | networks: 251 | behave: 252 | aliases: 253 | - ${CORE_PEER_NETWORKID} 254 | ports: 255 | - 7051:7051 256 | - 7053:7053 257 | 258 | peer0.org2.example.com: 259 | extends: 260 | file: docker-compose-base.yml 261 | service: peer 262 | container_name: peer0.org2.example.com 263 | environment: 264 | - CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052 265 | - CORE_PEER_ID=peer0.org2.example.com 266 | - CORE_PEER_ADDRESS=peer0.org2.example.com:7051 267 | - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 268 | - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 269 | - CORE_PEER_GOSSIP_ORGLEADER=${CORE_PEER_GOSSIP_ORGLEADER_PEER0_ORG2} 270 | - CORE_PEER_GOSSIP_USELEADERELECTION=${CORE_PEER_GOSSIP_USELEADERELECTION_PEER0_ORG2} 271 | - CORE_PEER_LOCALMSPID=Org2MSP 272 | - CORE_PEER_TLS_CLIENTROOTCAS_FILES=/var/hyperledger/users/Admin@org2.example.com/tls/ca.crt 273 | - CORE_PEER_TLS_CLIENTCERT_FILE=/var/hyperledger/users/Admin@org2.example.com/tls/client.crt 274 | - CORE_PEER_TLS_CLIENTKEY_FILE=/var/hyperledger/users/Admin@org2.example.com/tls/client.key 275 | volumes: 276 | - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/var/hyperledger/msp 277 | - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/var/hyperledger/tls 278 | - ../crypto-config/peerOrganizations/org2.example.com/users:/var/hyperledger/users 279 | - ../config/:/var/hyperledger/configs 280 | depends_on: 281 | - orderer0.example.com 282 | - orderer1.example.com 283 | - orderer2.example.com 284 | networks: 285 | behave: 286 | aliases: 287 | - ${CORE_PEER_NETWORKID} 288 | ports: 289 | - 9051:7051 290 | - 9053:7053 291 | 292 | peer1.org1.example.com: 293 | extends: 294 | file: docker-compose-base.yml 295 | service: peer 296 | container_name: peer1.org1.example.com 297 | environment: 298 | - CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7052 299 | - CORE_PEER_ID=peer1.org1.example.com 300 | - CORE_PEER_ADDRESS=peer1.org1.example.com:7051 301 | - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 302 | - CORE_PEER_GOSSIP_ORGLEADER=${CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG1} 303 | - CORE_PEER_GOSSIP_USELEADERELECTION=${CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG1} 304 | - CORE_PEER_LOCALMSPID=Org1MSP 305 | - CORE_PEER_TLS_CLIENTROOTCAS_FILES=/var/hyperledger/users/Admin@org1.example.com/tls/ca.crt 306 | - CORE_PEER_TLS_CLIENTCERT_FILE=/var/hyperledger/users/Admin@org1.example.com/tls/client.crt 307 | - CORE_PEER_TLS_CLIENTKEY_FILE=/var/hyperledger/users/Admin@org1.example.com/tls/client.key 308 | volumes: 309 | - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/var/hyperledger/msp 310 | - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/var/hyperledger/tls 311 | - ../crypto-config/peerOrganizations/org1.example.com/users:/var/hyperledger/users 312 | - ../config/:/var/hyperledger/configs 313 | depends_on: 314 | - orderer0.example.com 315 | - orderer1.example.com 316 | - orderer2.example.com 317 | - peer0.org1.example.com 318 | networks: 319 | behave: 320 | aliases: 321 | - ${CORE_PEER_NETWORKID} 322 | ports: 323 | - 8051:7051 324 | - 8053:7053 325 | 326 | peer1.org2.example.com: 327 | extends: 328 | file: docker-compose-base.yml 329 | service: peer 330 | container_name: peer1.org2.example.com 331 | environment: 332 | - CORE_PEER_CHAINCODELISTENADDRESS=peer1.org2.example.com:7052 333 | - CORE_PEER_ID=peer1.org2.example.com 334 | - CORE_PEER_ADDRESS=peer1.org2.example.com:7051 335 | - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 336 | - CORE_PEER_GOSSIP_ORGLEADER=${CORE_PEER_GOSSIP_ORGLEADER_PEER1_ORG2} 337 | - CORE_PEER_GOSSIP_USELEADERELECTION=${CORE_PEER_GOSSIP_USELEADERELECTION_PEER1_ORG2} 338 | - CORE_PEER_LOCALMSPID=Org2MSP 339 | - CORE_PEER_TLS_CLIENTROOTCAS_FILES=/var/hyperledger/users/Admin@org2.example.com/tls/ca.crt 340 | - CORE_PEER_TLS_CLIENTCERT_FILE=/var/hyperledger/users/Admin@org2.example.com/tls/client.crt 341 | - CORE_PEER_TLS_CLIENTKEY_FILE=/var/hyperledger/users/Admin@org2.example.com/tls/client.key 342 | volumes: 343 | - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/var/hyperledger/msp 344 | - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/var/hyperledger/tls 345 | - ../crypto-config/peerOrganizations/org2.example.com/users:/var/hyperledger/users 346 | - ../config/:/var/hyperledger/configs 347 | depends_on: 348 | - orderer0.example.com 349 | - orderer1.example.com 350 | - orderer2.example.com 351 | - peer0.org2.example.com 352 | networks: 353 | behave: 354 | aliases: 355 | - ${CORE_PEER_NETWORKID} 356 | ports: 357 | - 10051:7051 358 | - 10053:7053 359 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright IBM Corp All Rights Reserved 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | # Exit on first error, print all commands. 8 | set -ev 9 | 10 | # don't rewrite paths for Windows Git Bash users 11 | export MSYS_NO_PATHCONV=1 12 | 13 | docker-compose -f ./network-config/docker-compose-kafka.yml down 14 | docker-compose -f ./network-config/docker-compose-cli.yml down 15 | 16 | 17 | docker-compose -f ./network-config/docker-compose-kafka.yml up -d 18 | docker-compose -f ./network-config/docker-compose-cli.yml up -d 19 | 20 | # wait for Hyperledger Fabric to start 21 | # incase of errors when running later commands, issue export FABRIC_START_TIMEOUT= 22 | export FABRIC_START_TIMEOUT=10 23 | echo ${FABRIC_START_TIMEOUT} 24 | sleep ${FABRIC_START_TIMEOUT} 25 | 26 | # # # Create the channel 27 | docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/var/hyperledger/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer0.example.com:7050 -c mychannel -f /var/hyperledger/configs/channel.tx 28 | # # # Join peer0.org1.example.com to the channel. 29 | docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/var/hyperledger/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block 30 | -------------------------------------------------------------------------------- /stop.sh: -------------------------------------------------------------------------------- 1 | # stopping the containers. Note that this will remove all existing docker containers 2 | docker stop $(docker ps -q) 3 | docker rm $(docker ps -aq) -------------------------------------------------------------------------------- /teardown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright IBM Corp All Rights Reserved 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | # Exit on first error, print all commands. 8 | set -e 9 | 10 | # Shut down the Docker containers for the system tests. 11 | docker-compose -f ./network-config/docker-compose-kafka.yml kill && docker-compose -f ./network-config/docker-compose-kafka.yml down 12 | docker-compose -f ./network-config/docker-compose-cli.yml kill && docker-compose -f ./network-config/docker-compose-cli.yml down 13 | # remove the local state 14 | rm -f ~/.hfc-key-store/* 15 | 16 | # remove chaincode docker images 17 | docker rmi $(docker images net-* -q) 18 | 19 | # Your system is now clean 20 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | docker exec -it cli peer chaincode invoke -o orderer2.example.com:7050 -n mycc -c '{"Args":["set", "a", "20"]}' -C mychannel 2 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | rv="v$(shuf -i 200-10000 -n 1)" 2 | 3 | docker exec -it cli peer chaincode install -n mycc -p github.com/chaincode -v "$rv" 4 | 5 | docker exec -it cli peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc github.com/chaincode -v "$rv" -c '{"Args": ["a", "100"]}' --------------------------------------------------------------------------------