diff --git a/hyperledger/1.0/README.md b/hyperledger/1.0/README.md index 56c9e1ef..16944868 100644 --- a/hyperledger/1.0/README.md +++ b/hyperledger/1.0/README.md @@ -206,9 +206,9 @@ $ ./peer/scripts/new-channel-auto-test.sh ### Manually create artifacts (optional) -**Skip this step**, as we already put the needed artifacts `orderer_genesis.block` and `channel.tx` under `e2e_cli/channel-artifacts/`. +**Skip this step**, as we already put the needed artifacts `orderer.genesis.block` and `channel.tx` under `e2e_cli/channel-artifacts/`. -Detailed steps in [GenerateArtifacts](./GenerateArtifacts.md) explains the creation of `orderer_genesis.block` (needed by orderer to bootup) and `channel.tx` (needed by cli to create new channel) and crypto related configuration files. +Detailed steps in [GenerateArtifacts](artifacts_generation.md) explains the creation of `orderer.genesis.block` (needed by orderer to bootup) and `channel.tx` (needed by cli to create new channel) and crypto related configuration files. ### Create new channel diff --git a/hyperledger/1.0/example2/add-org.sh b/hyperledger/1.0/artifacts_generation/add-org.sh old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/example2/add-org.sh rename to hyperledger/1.0/artifacts_generation/add-org.sh diff --git a/hyperledger/1.0/GenerateArtifacts.md b/hyperledger/1.0/artifacts_generation/artifacts_generation.md similarity index 100% rename from hyperledger/1.0/GenerateArtifacts.md rename to hyperledger/1.0/artifacts_generation/artifacts_generation.md diff --git a/hyperledger/1.0/example2/configtx.yaml b/hyperledger/1.0/artifacts_generation/configtx.yaml old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/example2/configtx.yaml rename to hyperledger/1.0/artifacts_generation/configtx.yaml diff --git a/hyperledger/1.0/example2/crypto-config.yaml b/hyperledger/1.0/artifacts_generation/crypto-config.yaml old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/example2/crypto-config.yaml rename to hyperledger/1.0/artifacts_generation/crypto-config.yaml diff --git a/hyperledger/1.0/example2/docker-compose-2orgs.yml b/hyperledger/1.0/artifacts_generation/docker-compose-2orgs.yml old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/example2/docker-compose-2orgs.yml rename to hyperledger/1.0/artifacts_generation/docker-compose-2orgs.yml diff --git a/hyperledger/1.0/artifacts_generation/generateArtifacts.sh b/hyperledger/1.0/artifacts_generation/generateArtifacts.sh new file mode 100644 index 00000000..c78bff00 --- /dev/null +++ b/hyperledger/1.0/artifacts_generation/generateArtifacts.sh @@ -0,0 +1,103 @@ +#!/bin/bash +x +# +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + + +#set -e + +CHANNEL_NAME=$1 +: ${CHANNEL_NAME:="mychannel"} +echo $CHANNEL_NAME + +export FABRIC_ROOT=$PWD/../.. +export FABRIC_CFG_PATH=$PWD +echo + +OS_ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') + +## Using docker-compose template replace private key file names with constants +function replacePrivateKey () { + ARCH=`uname -s | grep Darwin` + if [ "$ARCH" == "Darwin" ]; then + OPTS="-it" + else + OPTS="-i" + fi + + cp docker-compose-e2e-template.yaml docker-compose-e2e.yaml + + CURRENT_DIR=$PWD + cd crypto-config/peerOrganizations/org1.example.com/ca/ + PRIV_KEY=$(ls *_sk) + cd $CURRENT_DIR + sed $OPTS "s/CA1_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose-e2e.yaml + cd crypto-config/peerOrganizations/org2.example.com/ca/ + PRIV_KEY=$(ls *_sk) + cd $CURRENT_DIR + sed $OPTS "s/CA2_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose-e2e.yaml +} + +## Generates Org certs using cryptogen tool +function generateCerts (){ + CRYPTOGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/cryptogen + + if [ -f "$CRYPTOGEN" ]; then + echo "Using cryptogen -> $CRYPTOGEN" + else + echo "Building cryptogen" + make -C $FABRIC_ROOT release + fi + + echo + echo "##########################################################" + echo "##### Generate certificates using cryptogen tool #########" + echo "##########################################################" + $CRYPTOGEN generate --config=./crypto-config.yaml + echo +} + +## Generate orderer genesis block , channel configuration transaction and anchor peer update transactions +function generateChannelArtifacts() { + + CONFIGTXGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/configtxgen + if [ -f "$CONFIGTXGEN" ]; then + echo "Using configtxgen -> $CONFIGTXGEN" + else + echo "Building configtxgen" + make -C $FABRIC_ROOT release + fi + + echo "##########################################################" + echo "######### Generating Orderer Genesis block ##############" + echo "##########################################################" + # Note: For some unknown reason (at least for now) the block file can't be + # named orderer.genesis.block or the orderer will fail to launch! + $CONFIGTXGEN -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block + + echo + echo "#################################################################" + echo "### Generating channel configuration transaction 'channel.tx' ###" + echo "#################################################################" + $CONFIGTXGEN -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME + + echo + echo "#################################################################" + echo "####### Generating anchor peer update for Org1MSP ##########" + echo "#################################################################" + $CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP + + echo + echo "#################################################################" + echo "####### Generating anchor peer update for Org2MSP ##########" + echo "#################################################################" + $CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP + echo +} + +generateCerts +replacePrivateKey +generateChannelArtifacts + diff --git a/hyperledger/1.0/example2/peer-base.yml b/hyperledger/1.0/artifacts_generation/peer-base.yml old mode 100755 new mode 100644 similarity index 97% rename from hyperledger/1.0/example2/peer-base.yml rename to hyperledger/1.0/artifacts_generation/peer-base.yml index c7566567..f8845e69 --- a/hyperledger/1.0/example2/peer-base.yml +++ b/hyperledger/1.0/artifacts_generation/peer-base.yml @@ -10,7 +10,7 @@ services: - ORDERER_GENERAL_LOGLEVEL=INFO - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - ORDERER_GENERAL_GENESISMETHOD=file - - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer_genesis.block #Need to be confirm orderer.block + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block #Need to be confirm orderer.block - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - ORDERER_GENERAL_LEDGERTYPE=ram @@ -26,7 +26,7 @@ services: ports: - "7050:7050" volumes: - - ./e2e_cli/channel-artifacts/orderer_genesis.block:/var/hyperledger/orderer/orderer_genesis.block + - ./e2e_cli/channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls command: orderer diff --git a/hyperledger/1.0/example2/new-channel-auto-test-5-peers.sh b/hyperledger/1.0/artifacts_generation/test-5-peers.sh old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/example2/new-channel-auto-test-5-peers.sh rename to hyperledger/1.0/artifacts_generation/test-5-peers.sh diff --git a/hyperledger/1.0/docker-compose-new-channel.yml b/hyperledger/1.0/docker-compose-1peer.yaml similarity index 96% rename from hyperledger/1.0/docker-compose-new-channel.yml rename to hyperledger/1.0/docker-compose-1peer.yaml index 6f02afaf..4dcd606b 100644 --- a/hyperledger/1.0/docker-compose-new-channel.yml +++ b/hyperledger/1.0/docker-compose-1peer.yaml @@ -25,7 +25,7 @@ services: - ORDERER_GENERAL_LOGLEVEL=INFO - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - ORDERER_GENERAL_GENESISMETHOD=file - - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer_genesis.block #Need to be confirm orderer.block + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block #Need to be confirm orderer.block - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - ORDERER_GENERAL_LEDGERTYPE=ram @@ -41,7 +41,7 @@ services: ports: - "7050:7050" volumes: - - ./e2e_cli/channel-artifacts/orderer_genesis.block:/var/hyperledger/orderer/orderer_genesis.block + - ./e2e_cli/channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls command: orderer diff --git a/hyperledger/1.0/docker-compose-2orgs.yml b/hyperledger/1.0/docker-compose-2orgs-4peers.yaml similarity index 75% rename from hyperledger/1.0/docker-compose-2orgs.yml rename to hyperledger/1.0/docker-compose-2orgs-4peers.yaml index fd58590b..47e3a66b 100644 --- a/hyperledger/1.0/docker-compose-2orgs.yml +++ b/hyperledger/1.0/docker-compose-2orgs-4peers.yaml @@ -1,9 +1,9 @@ # https://github.com/yeasy/docker-compose-files/tree/master/hyperledger # This compose file will start a Hyperledger Fabric 1.0 MVE, including -# * ca -# * orderer -# * peer -# * sdk for testing +# * 1 ca +# * 1 orderer +# * 4 peers in 2 orgs +# * cli for testing version: '2.0' @@ -18,70 +18,66 @@ services: command: fabric-ca-server start -b admin:adminpw orderer.example.com: # There can be multiple orderers - container_name: orderer.example.com extends: - file: peer-base.yml + file: docker-compose-base.yaml service: orderer.example.com peer0.org1.example.com: extends: - file: peer-base.yml + file: docker-compose-base.yaml service: peer0.org1.example.com - container_name: peer0.org1.example.com peer1.org1.example.com: extends: - file: peer-base.yml + file: docker-compose-base.yaml service: peer1.org1.example.com - container_name: peer1.org1.example.com peer0.org2.example.com: extends: - file: peer-base.yml + file: docker-compose-base.yaml service: peer0.org2.example.com - container_name: peer0.org2.example.com peer1.org2.example.com: extends: - file: peer-base.yml + file: docker-compose-base.yaml service: peer1.org2.example.com - container_name: peer1.org2.example.com cli: - extends: - file: peer.yml - service: peer container_name: fabric-cli - hostname: cli + hostname: fabric-cli + image: hyperledger/fabric-tools + tty: true environment: - - CORE_PEER_ID=cli - - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + - CORE_PEER_ID=fabric-cli + - CORE_LOGGING_LEVEL=DEBUG + - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 # default to operate on peer0.org1 - CORE_PEER_LOCALMSPID=Org1MSP - - CORE_PEER_TLS_ENABLED=false # to enable TLS, change to true + - CORE_PEER_TLS_ENABLED=true # to enable TLS, change to true - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp - links: - - orderer.example.com - - peer0.org1.example.com - - peer1.org1.example.com - - peer0.org2.example.com - - peer1.org2.example.com volumes: #- ./e2e_cli/examples:/opt/gopath/src/github.com/hyperledger/fabric/examples - ./e2e_cli/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ - - ./e2e_cli/crypto-config:/etc/hyperledger/fabric/crypto-config - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ - ./e2e_cli/channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts - - ./e2e_cli/configtx.yaml:/opt/gopath/src/github.com/hyperledger/fabric/peer/configtx.yaml - - ./e2e_cli/crypto-config.yaml:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto-config.yaml + - ./e2e_cli/crypto-config:/etc/hyperledger/fabric/crypto-config + - ./e2e_cli/configtx.yaml:/etc/hyperledger/fabric/peer/configtx.yaml + - ./e2e_cli/crypto-config.yaml:/etc/hyperledger/fabric/peer/crypto-config.yaml depends_on: - orderer.example.com - peer0.org1.example.com - peer1.org1.example.com - peer0.org2.example.com - peer1.org2.example.com + links: + - orderer.example.com + - peer0.org1.example.com + - peer1.org1.example.com + - peer0.org2.example.com + - peer1.org2.example.com + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer command: bash -c 'while true; do sleep 20170504; done' #networks: diff --git a/hyperledger/1.0/peer-base.yml b/hyperledger/1.0/docker-compose-base.yaml similarity index 53% rename from hyperledger/1.0/peer-base.yml rename to hyperledger/1.0/docker-compose-base.yaml index a9ad4b01..2454cf3f 100644 --- a/hyperledger/1.0/peer-base.yml +++ b/hyperledger/1.0/docker-compose-base.yaml @@ -1,64 +1,53 @@ -version: '2' +# Base compose files for: + +# orderer.example.com +# peer0.org1.example.com +# peer1.org1.example.com +# peer0.org2.example.com +# peer1.org2.example.com + + +version: '2' # v3 does not support 'extends' yet services: orderer.example.com: # There can be multiple orderers - image: hyperledger/fabric-orderer + extends: + file: orderer-base.yaml + service: orderer-base container_name: orderer.example.com hostname: orderer.example.com - environment: - - ORDERER_GENERAL_LOGLEVEL=INFO - - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - - ORDERER_GENERAL_GENESISMETHOD=file - - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer_genesis.block #Need to be confirm orderer.block - - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - - ORDERER_GENERAL_LEDGERTYPE=file - - ORDERER_GENERAL_BATCHTIMEOUT=10s - - ORDERER_GENERAL_MAXMESSAGECOUNT=10 - - ORDERER_GENERAL_MAXWINDOWSIZE=1000 - - ORDERER_GENERAL_LISTENPORT=7050 - - ORDERER_RAMLEDGER_HISTORY_SIZE=100 - - ORDERER_GENERAL_TLS_ENABLED=false # to enable TLS, make this true - - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key - - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt - - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] ports: - "7050:7050" volumes: - - ./e2e_cli/channel-artifacts/orderer_genesis.block:/var/hyperledger/orderer/orderer_genesis.block + - ./e2e_cli/channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - ./e2e_cli/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls - command: orderer + command: orderer start peer0.org1.example.com: extends: - file: peer.yml - service: peer + file: peer-base.yaml + service: peer-base container_name: peer0.org1.example.com hostname: peer0.org1.example.com environment: - CORE_PEER_ID=peer0.org1.example.com - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 - - CORE_PEER_GOSSIP_ORGLEADER=true - # - CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer.example.com:7050 - CORE_PEER_LOCALMSPID=Org1MSP - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - ports: - - 7051:7051 - - 7053:7053 volumes: - ./e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp - ./e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls - command: peer node start --peer-defaultchain=false + ports: + - 7051:7051 + - 7053:7053 + command: peer node start peer1.org1.example.com: extends: - file: peer.yml - service: peer + file: peer-base.yaml + service: peer-base container_name: peer1.org1.example.com hostname: peer1.org1.example.com environment: @@ -67,23 +56,18 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 - CORE_PEER_LOCALMSPID=Org1MSP - - CORE_PEER_GOSSIP_ORGLEADER=true - # - CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer.example.com:7050 - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - ports: - - 8051:7051 - - 8053:7053 volumes: - ./e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp - ./e2e_cli/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls - command: peer node start --peer-defaultchain=false + ports: + - 8051:7051 + - 8053:7053 + command: peer node start peer0.org2.example.com: extends: - file: peer.yml - service: peer + file: peer-base.yaml + service: peer-base container_name: peer0.org2.example.com hostname: peer0.org2.example.com environment: @@ -92,23 +76,18 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 - CORE_PEER_LOCALMSPID=Org2MSP - - CORE_PEER_GOSSIP_ORGLEADER=true - # - CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer.example.com:7050 - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - ports: - - 9051:7051 - - 9053:7053 volumes: - ./e2e_cli/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp - ./e2e_cli/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls - command: peer node start --peer-defaultchain=false + ports: + - 9051:7051 + - 9053:7053 + command: peer node start peer1.org2.example.com: extends: - file: peer.yml - service: peer + file: peer-base.yaml + service: peer-base container_name: peer1.org2.example.com hostname: peer1.org2.example.com environment: @@ -117,15 +96,10 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 - CORE_PEER_LOCALMSPID=Org2MSP - - CORE_PEER_GOSSIP_ORGLEADER=true - # - CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer.example.com:7050 - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - ports: - - 10051:7051 - - 10053:7053 volumes: - ./e2e_cli/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp - ./e2e_cli/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls - command: peer node start --peer-defaultchain=false + ports: + - 10051:7051 + - 10053:7053 + command: peer node start diff --git a/hyperledger/1.0/docker-compose-dev.yml b/hyperledger/1.0/docker-compose-dev.yaml similarity index 100% rename from hyperledger/1.0/docker-compose-dev.yml rename to hyperledger/1.0/docker-compose-dev.yaml diff --git a/hyperledger/1.0/docker-compose.yml b/hyperledger/1.0/docker-compose.yaml similarity index 92% rename from hyperledger/1.0/docker-compose.yml rename to hyperledger/1.0/docker-compose.yaml index 1168aa4f..ac800b7c 100644 --- a/hyperledger/1.0/docker-compose.yml +++ b/hyperledger/1.0/docker-compose.yaml @@ -24,7 +24,7 @@ services: container_name: fabric-orderer0 hostname: orderer0 environment: - - ORDERER_GENERAL_LEDGERTYPE=ram + - ORDERER_GENERAL_LEDGERTYPE=file - ORDERER_GENERAL_BATCHTIMEOUT=10s - ORDERER_GENERAL_MAXMESSAGECOUNT=10 - ORDERER_GENERAL_MAXWINDOWSIZE=1000 @@ -45,7 +45,6 @@ services: environment: - CORE_PEER_ID=peer0 - CORE_PEER_GOSSIP_ORGLEADER=true - # - CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer0:7050 links: - orderer0 ports: @@ -64,7 +63,6 @@ services: - CORE_PEER_ID=cli - CORE_PEER_ADDRESS=peer0:7051 #- CORE_PEER_LOCALMSPID=Org0MSP - #- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 links: - peer0 - orderer0 diff --git a/hyperledger/1.0/e2e_cli/base/docker-compose-base.yaml b/hyperledger/1.0/e2e_cli/base/docker-compose-base.yaml new file mode 100644 index 00000000..7a97e718 --- /dev/null +++ b/hyperledger/1.0/e2e_cli/base/docker-compose-base.yaml @@ -0,0 +1,108 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +services: + + orderer.example.com: + container_name: orderer.example.com + image: hyperledger/fabric-orderer + environment: + - ORDERER_GENERAL_LOGLEVEL=debug + - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 + - ORDERER_GENERAL_GENESISMETHOD=file + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block + - ORDERER_GENERAL_LOCALMSPID=OrdererMSP + - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp + # enabled TLS + - ORDERER_GENERAL_TLS_ENABLED=true + - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + working_dir: /opt/gopath/src/github.com/hyperledger/fabric + command: orderer + volumes: + - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp + - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls + ports: + - 7050:7050 + + peer0.org1.example.com: + container_name: peer0.org1.example.com + extends: + file: peer-base.yaml + service: peer-base + environment: + - CORE_PEER_ID=peer0.org1.example.com + - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 + - CORE_PEER_LOCALMSPID=Org1MSP + volumes: + - /var/run/:/host/var/run/ + - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp + - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls + ports: + - 7051:7051 + - 7053:7053 + + peer1.org1.example.com: + container_name: peer1.org1.example.com + extends: + file: peer-base.yaml + service: peer-base + environment: + - CORE_PEER_ID=peer1.org1.example.com + - CORE_PEER_ADDRESS=peer1.org1.example.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 + - CORE_PEER_LOCALMSPID=Org1MSP + volumes: + - /var/run/:/host/var/run/ + - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp + - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls + + ports: + - 8051:7051 + - 8053:7053 + + peer0.org2.example.com: + container_name: peer0.org2.example.com + extends: + file: peer-base.yaml + service: peer-base + environment: + - CORE_PEER_ID=peer0.org2.example.com + - CORE_PEER_ADDRESS=peer0.org2.example.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 + - CORE_PEER_LOCALMSPID=Org2MSP + volumes: + - /var/run/:/host/var/run/ + - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp + - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls + ports: + - 9051:7051 + - 9053:7053 + + peer1.org2.example.com: + container_name: peer1.org2.example.com + extends: + file: peer-base.yaml + service: peer-base + environment: + - CORE_PEER_ID=peer1.org2.example.com + - CORE_PEER_ADDRESS=peer1.org2.example.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 + - CORE_PEER_LOCALMSPID=Org2MSP + volumes: + - /var/run/:/host/var/run/ + - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp + - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls + ports: + - 10051:7051 + - 10053:7053 diff --git a/hyperledger/1.0/e2e_cli/base/peer-base.yaml b/hyperledger/1.0/e2e_cli/base/peer-base.yaml new file mode 100644 index 00000000..9a3a3fb6 --- /dev/null +++ b/hyperledger/1.0/e2e_cli/base/peer-base.yaml @@ -0,0 +1,27 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' +services: + peer-base: + image: hyperledger/fabric-peer + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + # the following setting starts chaincode containers on the same + # bridge network as the peers + # https://docs.docker.com/compose/networking/ + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2ecli_default + #- CORE_LOGGING_LEVEL=ERROR + - CORE_LOGGING_LEVEL=DEBUG + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_ENDORSER_ENABLED=true + - CORE_PEER_GOSSIP_USELEADERELECTION=true + - CORE_PEER_GOSSIP_ORGLEADER=false + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: peer node start diff --git a/hyperledger/1.0/e2e_cli/channel-artifacts/.gitkeep b/hyperledger/1.0/e2e_cli/channel-artifacts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/hyperledger/1.0/e2e_cli/channel-artifacts/orderer_genesis.block b/hyperledger/1.0/e2e_cli/channel-artifacts/orderer.genesis.block similarity index 100% rename from hyperledger/1.0/e2e_cli/channel-artifacts/orderer_genesis.block rename to hyperledger/1.0/e2e_cli/channel-artifacts/orderer.genesis.block diff --git a/hyperledger/1.0/e2e_cli/configtx.yaml b/hyperledger/1.0/e2e_cli/configtx.yaml index 85d0fe89..e60d789e 100644 --- a/hyperledger/1.0/e2e_cli/configtx.yaml +++ b/hyperledger/1.0/e2e_cli/configtx.yaml @@ -1,3 +1,8 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + --- ################################################################################ # @@ -50,18 +55,6 @@ Organizations: # MSPDir is the filesystem path which contains the MSP configuration MSPDir: crypto-config/ordererOrganizations/example.com/msp - # BCCSP (Blockchain crypto provider): Select which crypto implementation or - # library to use - BCCSP: - Default: SW - SW: - Hash: SHA2 - Security: 256 - # Location of Key Store. If this is unset, a location will - # be chosen using 'MSPDir'/keystore - FileKeyStore: - KeyStore: - - &Org1 # DefaultOrg defines the organization which is used in the sampleconfig # of the fabric.git development environment @@ -72,18 +65,6 @@ Organizations: MSPDir: crypto-config/peerOrganizations/org1.example.com/msp - # BCCSP (Blockchain crypto provider): Select which crypto implementation or - # library to use - BCCSP: - Default: SW - SW: - Hash: SHA2 - Security: 256 - # Location of Key Store. If this is unset, a location will - # be chosen using 'MSPDir'/keystore - FileKeyStore: - KeyStore: - AnchorPeers: # AnchorPeers defines the location of peers which can be used # for cross org gossip communication. Note, this value is only @@ -101,18 +82,6 @@ Organizations: MSPDir: crypto-config/peerOrganizations/org2.example.com/msp - # BCCSP (Blockchain crypto provider): Select which crypto implementation or - # library to use - BCCSP: - Default: SW - SW: - Hash: SHA2 - Security: 256 - # Location of Key Store. If this is unset, a location will - # be chosen using 'MSPDir'/keystore - FileKeyStore: - KeyStore: - AnchorPeers: # AnchorPeers defines the location of peers which can be used # for cross org gossip communication. Note, this value is only diff --git a/hyperledger/1.0/e2e_cli/crypto-config.yaml b/hyperledger/1.0/e2e_cli/crypto-config.yaml index 9c9c30bc..06ad8185 100644 --- a/hyperledger/1.0/e2e_cli/crypto-config.yaml +++ b/hyperledger/1.0/e2e_cli/crypto-config.yaml @@ -1,3 +1,8 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + # --------------------------------------------------------------------------- # "OrdererOrgs" - Definition of organizations managing orderer nodes # --------------------------------------------------------------------------- diff --git a/hyperledger/1.0/e2e_cli/crypto/orderer/channel.tx b/hyperledger/1.0/e2e_cli/crypto/orderer/channel.tx deleted file mode 100644 index 8db454ce..00000000 Binary files a/hyperledger/1.0/e2e_cli/crypto/orderer/channel.tx and /dev/null differ diff --git a/hyperledger/1.0/e2e_cli/crypto/orderer/orderer.block b/hyperledger/1.0/e2e_cli/crypto/orderer/orderer.block deleted file mode 100644 index b541e4be..00000000 Binary files a/hyperledger/1.0/e2e_cli/crypto/orderer/orderer.block and /dev/null differ diff --git a/hyperledger/1.0/e2e_cli/docker-compose-cli.yaml b/hyperledger/1.0/e2e_cli/docker-compose-cli.yaml new file mode 100644 index 00000000..e6290cf1 --- /dev/null +++ b/hyperledger/1.0/e2e_cli/docker-compose-cli.yaml @@ -0,0 +1,69 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +services: + + orderer.example.com: + extends: + file: base/docker-compose-base.yaml + service: orderer.example.com + container_name: orderer.example.com + + peer0.org1.example.com: + container_name: peer0.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org1.example.com + + peer1.org1.example.com: + container_name: peer1.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org1.example.com + + peer0.org2.example.com: + container_name: peer0.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org2.example.com + + peer1.org2.example.com: + container_name: peer1.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org2.example.com + + cli: + container_name: cli + image: hyperledger/fabric-tools + tty: true + environment: + - GOPATH=/opt/gopath + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_LOGGING_LEVEL=DEBUG + - CORE_PEER_ID=cli + - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + - CORE_PEER_LOCALMSPID=Org1MSP + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt + - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT' + volumes: + - /var/run/:/host/var/run/ + - ../chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go + - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ + - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ + - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts + depends_on: + - orderer.example.com + - peer0.org1.example.com + - peer1.org1.example.com + - peer0.org2.example.com + - peer1.org2.example.com diff --git a/hyperledger/1.0/e2e_cli/docker-compose-couch.yaml b/hyperledger/1.0/e2e_cli/docker-compose-couch.yaml new file mode 100644 index 00000000..d2049b7f --- /dev/null +++ b/hyperledger/1.0/e2e_cli/docker-compose-couch.yaml @@ -0,0 +1,67 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +services: + couchdb0: + container_name: couchdb0 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "5984:5984" + + peer0.org1.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984 + depends_on: + - couchdb0 + + couchdb1: + container_name: couchdb1 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "6984:5984" + + peer1.org1.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984 + depends_on: + - couchdb1 + + couchdb2: + container_name: couchdb2 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "7984:5984" + + peer0.org2.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984 + depends_on: + - couchdb2 + + couchdb3: + container_name: couchdb3 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "8984:5984" + + peer1.org2.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984 + depends_on: + - couchdb3 diff --git a/hyperledger/1.0/e2e_cli/docker-compose-e2e-template.yaml b/hyperledger/1.0/e2e_cli/docker-compose-e2e-template.yaml new file mode 100644 index 00000000..d30d0ef5 --- /dev/null +++ b/hyperledger/1.0/e2e_cli/docker-compose-e2e-template.yaml @@ -0,0 +1,67 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +services: + ca0: + image: hyperledger/fabric-ca + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org1 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY + ports: + - "7054:7054" + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY -b admin:adminpw -d' + volumes: + - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config + container_name: ca_peerOrg1 + + ca1: + image: hyperledger/fabric-ca + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org2 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY + ports: + - "8054:7054" + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY -b admin:adminpw -d' + volumes: + - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config + container_name: ca_peerOrg2 + + orderer.example.com: + extends: + file: base/docker-compose-base.yaml + service: orderer.example.com + container_name: orderer.example.com + + peer0.org1.example.com: + container_name: peer0.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org1.example.com + + peer1.org1.example.com: + container_name: peer1.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org1.example.com + + peer0.org2.example.com: + container_name: peer0.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org2.example.com + + peer1.org2.example.com: + container_name: peer1.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org2.example.com diff --git a/hyperledger/1.0/e2e_cli/docker-compose-e2e.yaml b/hyperledger/1.0/e2e_cli/docker-compose-e2e.yaml new file mode 100644 index 00000000..5fdfd003 --- /dev/null +++ b/hyperledger/1.0/e2e_cli/docker-compose-e2e.yaml @@ -0,0 +1,67 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +services: + ca0: + image: hyperledger/fabric-ca + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org1 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/2628c774d6def25e2bf6147c30f25fe76469d63d257965ac867544acd090148c_sk + ports: + - "7054:7054" + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/2628c774d6def25e2bf6147c30f25fe76469d63d257965ac867544acd090148c_sk -b admin:adminpw -d' + volumes: + - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config + container_name: ca_peerOrg1 + + ca1: + image: hyperledger/fabric-ca + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org2 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem + - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/3f39c678fc9b1f79cddb94f1e896cc3c487aa25c2ebf8b7f3e0205c2d21a37ec_sk + ports: + - "8054:7054" + command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/3f39c678fc9b1f79cddb94f1e896cc3c487aa25c2ebf8b7f3e0205c2d21a37ec_sk -b admin:adminpw -d' + volumes: + - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config + container_name: ca_peerOrg2 + + orderer.example.com: + extends: + file: base/docker-compose-base.yaml + service: orderer.example.com + container_name: orderer.example.com + + peer0.org1.example.com: + container_name: peer0.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org1.example.com + + peer1.org1.example.com: + container_name: peer1.org1.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org1.example.com + + peer0.org2.example.com: + container_name: peer0.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer0.org2.example.com + + peer1.org2.example.com: + container_name: peer1.org2.example.com + extends: + file: base/docker-compose-base.yaml + service: peer1.org2.example.com diff --git a/hyperledger/1.0/orderer-base.yaml b/hyperledger/1.0/orderer-base.yaml new file mode 100644 index 00000000..74da487c --- /dev/null +++ b/hyperledger/1.0/orderer-base.yaml @@ -0,0 +1,32 @@ +# This is the default base file to config env and command +# Notice that chaincode is executed inside docker in default net mode +# https://github.com/yeasy/docker-compose-files + +# Depends on the hyperledger/fabric-orderer image. + +version: '2' + +services: + orderer-base: + image: hyperledger/fabric-orderer + environment: + - ORDERER_GENERAL_LOGLEVEL=DEBUG + - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 + - ORDERER_GENERAL_GENESISMETHOD=file + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block + - ORDERER_GENERAL_LOCALMSPID=OrdererMSP + - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp + - ORDERER_GENERAL_LEDGERTYPE=file + - ORDERER_GENERAL_BATCHTIMEOUT=2s + - ORDERER_GENERAL_MAXMESSAGECOUNT=10 + - ORDERER_GENERAL_MAXWINDOWSIZE=1000 + - ORDERER_GENERAL_LISTENPORT=7050 + #- ORDERER_RAMLEDGER_HISTORY_SIZE=100 #only useful when use ram ledger + # enabled TLS + - ORDERER_GENERAL_TLS_ENABLED=true + - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + expose: + - "7050" # + command: orderer start diff --git a/hyperledger/1.0/peer-dev.yml b/hyperledger/1.0/peer-base-dev.yaml similarity index 74% rename from hyperledger/1.0/peer-dev.yml rename to hyperledger/1.0/peer-base-dev.yaml index 84ae72c8..c54dc4d4 100644 --- a/hyperledger/1.0/peer-dev.yml +++ b/hyperledger/1.0/peer-base-dev.yaml @@ -7,7 +7,7 @@ version: '2' services: - peer: + peer-base: image: yeasy/hyperledger-fabric environment: #- CORE_PEER_ID=peer0 @@ -15,17 +15,15 @@ services: - CORE_LOGGING_LEVEL=DEBUG #- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hyperledger_fabric # uncomment this to use specific network #- CORE_PEER_NETWORKID=dev - - CORE_NEXT=true - CORE_PEER_ENDORSER_ENABLED=true - CORE_PEER_COMMITTER_ENABLED=true + - CORE_PEER_GOSSIP_USELEADERELECTION=true + - CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to false - CORE_PEER_PROFILE_ENABLED=false - - CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to true - - CORE_PEER_GOSSIP_USELEADERELECTION=false # automatically run leader election, default to false - - CORE_PEER_GOSSIP_IGNORESECURITY=true - # The following setting skips the gossip handshake since we are - # are not doing mutual TLS - - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true - #- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt expose: - "7050" # Rest - "7051" # Grpc @@ -39,6 +37,7 @@ services: - "7059" # tlsCAA volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT - /var/run/docker.sock:/var/run/docker.sock + - $GOPATH/src/github.com/hyperledger/:/go/src/github.com/hyperledger/ #volumes: # - /var/run/:/host/var/run/ command: peer node start diff --git a/hyperledger/1.0/peer.yml b/hyperledger/1.0/peer-base.yaml similarity index 72% rename from hyperledger/1.0/peer.yml rename to hyperledger/1.0/peer-base.yaml index b111cff7..50c1a7c0 100644 --- a/hyperledger/1.0/peer.yml +++ b/hyperledger/1.0/peer-base.yaml @@ -7,25 +7,23 @@ version: '2' services: - peer: + peer-base: image: hyperledger/fabric-peer environment: - #- CORE_PEER_ID=peer0 + #- CORE_PEER_ID=peer0 - CORE_PEER_ADDRESSAUTODETECT=true - CORE_LOGGING_LEVEL=DEBUG #- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hyperledger_fabric # uncomment this to use specific network #- CORE_PEER_NETWORKID=dev - - CORE_NEXT=true - CORE_PEER_ENDORSER_ENABLED=true - CORE_PEER_COMMITTER_ENABLED=true + - CORE_PEER_GOSSIP_USELEADERELECTION=true + - CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to false - CORE_PEER_PROFILE_ENABLED=false - - CORE_PEER_GOSSIP_ORGLEADER=false # this node is the group leader, default to true - - CORE_PEER_GOSSIP_USELEADERELECTION=false # automatically run leader election, default to false - - CORE_PEER_GOSSIP_IGNORESECURITY=true - # The following setting skips the gossip handshake since we are - # are not doing mutual TLS - - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true - #- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt expose: - "7050" # Rest - "7051" # Grpc diff --git a/hyperledger/1.0/scripts/download_images.sh b/hyperledger/1.0/scripts/download_images.sh index 23af498f..fbb0fff5 100644 --- a/hyperledger/1.0/scripts/download_images.sh +++ b/hyperledger/1.0/scripts/download_images.sh @@ -1,13 +1,16 @@ #!/usr/bin/env bash -source ./header.sh +source scripts/header.sh ARCH=x86_64 -BASE_VERSION=1.0.0-preview +BASE_VERSION=0.3.1 PROJECT_VERSION=1.0.0-preview IMG_VERSION=0.9.4 -echo_b "Downloading images from DockerHub..." +# For testing latest images +IMG_VERSION=latest + +echo_b "Downloading images from DockerHub... need a while" docker pull yeasy/hyperledger-fabric-base:$IMG_VERSION \ && docker pull yeasy/hyperledger-fabric-peer:$IMG_VERSION \ @@ -19,7 +22,10 @@ docker pull yeasy/hyperledger-fabric-base:$IMG_VERSION \ echo_b "Rename images with official tags..." docker tag yeasy/hyperledger-fabric-peer:$IMG_VERSION hyperledger/fabric-peer \ + && docker tag yeasy/hyperledger-fabric-peer:$IMG_VERSION hyperledger/fabric-tools \ && docker tag yeasy/hyperledger-fabric-orderer:$IMG_VERSION hyperledger/fabric-orderer \ && docker tag yeasy/hyperledger-fabric-ca:$IMG_VERSION hyperledger/fabric-ca \ - && docker tag yeasy/hyperledger-fabric-base:$IMG_VERSION hyperledger/fabric-ccenv:$ARCH-$BASE_VERSION \ + && docker tag yeasy/hyperledger-fabric-base:$IMG_VERSION hyperledger/fabric-ccenv:$ARCH-$PROJECT_VERSION \ && docker tag yeasy/hyperledger-fabric-base:$IMG_VERSION hyperledger/fabric-baseos:$ARCH-$BASE_VERSION + +echo_g "Done, now can startup the network using docker-compose..." \ No newline at end of file diff --git a/hyperledger/1.0/scripts/start_fabric.sh b/hyperledger/1.0/scripts/start_fabric.sh index 309098cf..0a3191db 100644 --- a/hyperledger/1.0/scripts/start_fabric.sh +++ b/hyperledger/1.0/scripts/start_fabric.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -source ./scripts/header.sh +source scripts/header.sh -COMPOSE_FILE=${1:-"docker-compose-2orgs.yml"} +COMPOSE_FILE=${1:-"docker-compose-2orgs-4peers.yml"} echo_b "Start up with ${COMPOSE_FILE}" diff --git a/hyperledger/1.0/scripts/new-channel-auto-test.sh b/hyperledger/1.0/scripts/test_1peer.sh old mode 100755 new mode 100644 similarity index 100% rename from hyperledger/1.0/scripts/new-channel-auto-test.sh rename to hyperledger/1.0/scripts/test_1peer.sh diff --git a/hyperledger/1.0/scripts/new-channel-auto-test-4-peers.sh b/hyperledger/1.0/scripts/test_4peers.sh similarity index 90% rename from hyperledger/1.0/scripts/new-channel-auto-test-4-peers.sh rename to hyperledger/1.0/scripts/test_4peers.sh index f502b6f5..94634114 100644 --- a/hyperledger/1.0/scripts/new-channel-auto-test-4-peers.sh +++ b/hyperledger/1.0/scripts/test_4peers.sh @@ -56,9 +56,9 @@ createChannel() { setGlobals 0 if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./peer/channel-artifacts/channel.tx >&log.txt + peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt else - peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./peer/channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt fi res=$? cat log.txt @@ -72,9 +72,9 @@ updateAnchorPeers() { setGlobals $PEER if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./peer/channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt + peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt else - peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./peer/channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt fi res=$? cat log.txt @@ -192,15 +192,15 @@ echo "Having all peers join the channel..." joinChannel ## Set the anchor peers for each org in the channel -echo "Updating anchor peers using peer0/org1(peer0) for org1..." +echo "Updating anchor peers for org1..." updateAnchorPeers 0 -echo "Updating anchor peers using peer0/org2(peer2) for org2..." +echo "Updating anchor peers for org2..." updateAnchorPeers 2 -## Install chaincode on Peer0/Org1 and Peer0/Org2 -echo "Installing chaincode on peer0/org1..." +## Install chaincode on Peer0/Org1 and Peer2/Org2 +echo "Installing chaincode on org1/peer0..." installChaincode 0 -echo "Install chaincode on peer0/org2.." +echo "Install chaincode on org2/peer2..." installChaincode 2 #Instantiate chaincode on Peer0/Org2 @@ -208,11 +208,11 @@ echo "Instantiating chaincode on peer0/org2..." instantiateChaincode 2 #Query on chaincode on Peer0/Org1 -echo "Querying chaincode on peer0/org1..." +echo "Querying chaincode on org1/peer0..." chaincodeQuery 0 100 #Invoke on chaincode on Peer0/Org1 -echo "Sending invoke transaction on peer0/org1..." +echo "Sending invoke transaction on org1/peer0..." chaincodeInvoke 0 ## Install chaincode on Peer1/Org2