Skip to content

Commit

Permalink
Channel setup instruction
Browse files Browse the repository at this point in the history
Adding docker info from Murali, including
1) docker-compose file
2) instruction to run with docker images

Change-Id: I7b3511f3774e5490e42d7aba0a95691b5e08b166
Signed-off-by: Binh Q. Nguyen <binhn@us.ibm.com>
  • Loading branch information
binhn committed Jan 17, 2017
1 parent 6da52bc commit d12363d
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 16 deletions.
73 changes: 57 additions & 16 deletions docs/channel-setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Channel create/join chain support
# Multichannel Setup

This document describe the CLI for creating channels and directing peers to join channels. The CLI uses channel APIs that are also available in the SDK.

The channel commands are
* create - create a channel in the `orderer` and get back a genesis block for the channel
Expand All @@ -14,10 +16,59 @@ The commands are work in progress. In particular, there will be more configurati
https://jira.hyperledger.org/browse/FAB-1639
https://jira.hyperledger.org/browse/FAB-1580
```
Assuming the orderer and peer have been built, and the executables are available in build/bin directory. Switch to build/bin directory.

## Create a channel
### Using CLI in Vagrant environment
## Using docker
Pull the latest images from https://github.com/rameshthoomu/

### Create a channel
Copy [`docker-compose-channel.yml`](docker-compose-channel.yml) to your current directory.

_Bring up peer and orderer_
```
cd docs
docker-compose -f docker-compose-channel.yml up
```

`docker ps` should show containers `orderer` and `peer0` running.

_Ask orderer to create a channel_
Start the CLI container.
```
docker-compose -f docker-compose-channel.yml run cli
```
In the above shell execute the create command
```
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer channel create -c myc1
```
This will create a channel genesis block file `myc1.block` to issue join commands with.

### Join a channel
Execute the join command to peer0 in the CLI container.

```
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc1.block
```

### Use the channel to deploy and invoke chaincodes
Run the deploy command
```
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer chaincode deploy -C myc1 -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a","100","b","200"]}'
```

Run the invoke command
```
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer chaincode invoke -C myc1 -n mycc -c '{"Args":["invoke","a","b","10"]}'
```

Run the query command
```
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer chaincode query -C myc1 -n mycc -c '{"Args":["query","a"]}'
```

## Using Vagrant
Build the executables with `make orderer` and `make peer` commands. Switch to build/bin directory.

### Create a channel
_Vagrant window 1 - start orderer_

```
Expand All @@ -31,11 +82,7 @@ peer channel create -c myc1

On successful creation, a genesis block myc1.block is saved in build/bin directory.

### Using docker environment
TODO

## Join a channel
### Using CLI in Vagrant environment
### Join a channel
_Vagrant window 3 - start the peer in a "chainless" mode_

```
Expand All @@ -59,12 +106,8 @@ peer channel join -b myc1.block

where myc1.block is the block that was received from the `orderer` from the create channel command.

### Using docker environment
TODO

At this point we can issue transactions.
## Use the channel to deploy and invoke chaincodes
### Using CLI in Vagrant environment
### Use the channel to deploy and invoke chaincodes
_Vagrant window 2 - deploy a chaincode to myc1_

```
Expand All @@ -88,7 +131,5 @@ _Vagrant window 2 - query chaincode_
```
peer chaincode query -C myc1 -n mycc -c '{"Args":["query","a"]}'
```
### Using docker environment
TODO

To reset, clear out the `fileSystemPath` directory (defined in core.yaml) and myc1.block.
81 changes: 81 additions & 0 deletions docs/docker-compose-channel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
version: '2'
networks:
bridge:

services:
orderer:
container_name: orderer
image: hyperledger/fabric-orderer
environment:
- ORDERER_GENERAL_LEDGERTYPE=ram
- ORDERER_GENERAL_BATCHTIMEOUT=10s
- ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT=10
- ORDERER_GENERAL_MAXWINDOWSIZE=1000
- ORDERER_GENERAL_ORDERERTYPE=solo
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_LISTENPORT=5005
- ORDERER_RAMLEDGER_HISTORY_SIZE=100
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
- 5005:5005
networks:
- bridge

peer0:
container_name: peer0
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_NETWORKID=peer0
- CORE_NEXT=true
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_ID=peer0
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005
- CORE_PEER_GOSSIP_ORGLEADER=true
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
ports:
- 7051:7051
- 7053:7053
command: peer node start --peer-defaultchain=false
links:
- orderer:orderer
volumes:
- /var/run/:/host/var/run/
depends_on:
- orderer
networks:
- bridge

cli:
container_name: cli
image: hyperledger/fabric-peer
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_NEXT=true
- CORE_PEER_ID=cli
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005
- CORE_PEER_ADDRESS=peer0:7051
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/sh
links:
- orderer:orderer
- peer0:peer0
volumes:
- /var/run/:/host/var/run/
#in the "- <HOST>:/opt/gopath/src/github.com/hyperledger/fabric/examples/" mapping below, the HOST part
#should be modified to the path on the host. This will work as is in the Vagrant environment
- /opt/gopath/src/github.com/hyperledger/fabric/examples/:/opt/gopath/src/github.com/hyperledger/fabric/examples/
depends_on:
- orderer
- peer0
networks:
- bridge

0 comments on commit d12363d

Please sign in to comment.