Skip to content

Commit d12363d

Browse files
committed
Channel setup instruction
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 <[email protected]>
1 parent 6da52bc commit d12363d

File tree

2 files changed

+138
-16
lines changed

2 files changed

+138
-16
lines changed

docs/channel-setup.md

+57-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Channel create/join chain support
1+
# Multichannel Setup
2+
3+
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.
24

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

19-
## Create a channel
20-
### Using CLI in Vagrant environment
20+
## Using docker
21+
Pull the latest images from https://github.com/rameshthoomu/
22+
23+
### Create a channel
24+
Copy [`docker-compose-channel.yml`](docker-compose-channel.yml) to your current directory.
25+
26+
_Bring up peer and orderer_
27+
```
28+
cd docs
29+
docker-compose -f docker-compose-channel.yml up
30+
```
31+
32+
`docker ps` should show containers `orderer` and `peer0` running.
33+
34+
_Ask orderer to create a channel_
35+
Start the CLI container.
36+
```
37+
docker-compose -f docker-compose-channel.yml run cli
38+
```
39+
In the above shell execute the create command
40+
```
41+
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer channel create -c myc1
42+
```
43+
This will create a channel genesis block file `myc1.block` to issue join commands with.
44+
45+
### Join a channel
46+
Execute the join command to peer0 in the CLI container.
47+
48+
```
49+
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc1.block
50+
```
51+
52+
### Use the channel to deploy and invoke chaincodes
53+
Run the deploy command
54+
```
55+
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"]}'
56+
```
57+
58+
Run the invoke command
59+
```
60+
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"]}'
61+
```
62+
63+
Run the query command
64+
```
65+
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005 peer chaincode query -C myc1 -n mycc -c '{"Args":["query","a"]}'
66+
```
67+
68+
## Using Vagrant
69+
Build the executables with `make orderer` and `make peer` commands. Switch to build/bin directory.
70+
71+
### Create a channel
2172
_Vagrant window 1 - start orderer_
2273

2374
```
@@ -31,11 +82,7 @@ peer channel create -c myc1
3182

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

34-
### Using docker environment
35-
TODO
36-
37-
## Join a channel
38-
### Using CLI in Vagrant environment
85+
### Join a channel
3986
_Vagrant window 3 - start the peer in a "chainless" mode_
4087

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

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

62-
### Using docker environment
63-
TODO
64-
65109
At this point we can issue transactions.
66-
## Use the channel to deploy and invoke chaincodes
67-
### Using CLI in Vagrant environment
110+
### Use the channel to deploy and invoke chaincodes
68111
_Vagrant window 2 - deploy a chaincode to myc1_
69112

70113
```
@@ -88,7 +131,5 @@ _Vagrant window 2 - query chaincode_
88131
```
89132
peer chaincode query -C myc1 -n mycc -c '{"Args":["query","a"]}'
90133
```
91-
### Using docker environment
92-
TODO
93134

94135
To reset, clear out the `fileSystemPath` directory (defined in core.yaml) and myc1.block.

docs/docker-compose-channel.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
version: '2'
2+
networks:
3+
bridge:
4+
5+
services:
6+
orderer:
7+
container_name: orderer
8+
image: hyperledger/fabric-orderer
9+
environment:
10+
- ORDERER_GENERAL_LEDGERTYPE=ram
11+
- ORDERER_GENERAL_BATCHTIMEOUT=10s
12+
- ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT=10
13+
- ORDERER_GENERAL_MAXWINDOWSIZE=1000
14+
- ORDERER_GENERAL_ORDERERTYPE=solo
15+
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
16+
- ORDERER_GENERAL_LISTENPORT=5005
17+
- ORDERER_RAMLEDGER_HISTORY_SIZE=100
18+
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
19+
command: orderer
20+
ports:
21+
- 5005:5005
22+
networks:
23+
- bridge
24+
25+
peer0:
26+
container_name: peer0
27+
image: hyperledger/fabric-peer
28+
environment:
29+
- CORE_PEER_ADDRESSAUTODETECT=true
30+
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
31+
- CORE_LOGGING_LEVEL=DEBUG
32+
- CORE_PEER_NETWORKID=peer0
33+
- CORE_NEXT=true
34+
- CORE_PEER_ENDORSER_ENABLED=true
35+
- CORE_PEER_ID=peer0
36+
- CORE_PEER_PROFILE_ENABLED=true
37+
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005
38+
- CORE_PEER_GOSSIP_ORGLEADER=true
39+
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
40+
ports:
41+
- 7051:7051
42+
- 7053:7053
43+
command: peer node start --peer-defaultchain=false
44+
links:
45+
- orderer:orderer
46+
volumes:
47+
- /var/run/:/host/var/run/
48+
depends_on:
49+
- orderer
50+
networks:
51+
- bridge
52+
53+
cli:
54+
container_name: cli
55+
image: hyperledger/fabric-peer
56+
tty: true
57+
environment:
58+
- GOPATH=/opt/gopath
59+
- CORE_PEER_ADDRESSAUTODETECT=true
60+
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
61+
- CORE_LOGGING_LEVEL=DEBUG
62+
- CORE_NEXT=true
63+
- CORE_PEER_ID=cli
64+
- CORE_PEER_ENDORSER_ENABLED=true
65+
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:5005
66+
- CORE_PEER_ADDRESS=peer0:7051
67+
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
68+
command: /bin/sh
69+
links:
70+
- orderer:orderer
71+
- peer0:peer0
72+
volumes:
73+
- /var/run/:/host/var/run/
74+
#in the "- <HOST>:/opt/gopath/src/github.com/hyperledger/fabric/examples/" mapping below, the HOST part
75+
#should be modified to the path on the host. This will work as is in the Vagrant environment
76+
- /opt/gopath/src/github.com/hyperledger/fabric/examples/:/opt/gopath/src/github.com/hyperledger/fabric/examples/
77+
depends_on:
78+
- orderer
79+
- peer0
80+
networks:
81+
- bridge

0 commit comments

Comments
 (0)