Skip to content

Commit 0217469

Browse files
ghaskinsmastersingh24
authored andcommitted
[FAB-5579] Add support for couchdb to examples/cluster
This patch simply adds support for couchdb configuration as the default for "make compose". Future additions may allow this to be an option. Fixes FAB-5579 Change-Id: Icefc99ac2d83509c9896af359d7727f73190dc71 Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>
1 parent 73693f7 commit 0217469

File tree

3 files changed

+79
-17
lines changed

3 files changed

+79
-17
lines changed

examples/cluster/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mspmap.cli := $(USERS_PATH)/Admin@org1.net
3434

3535
RELEASE ?= latest
3636
CA_RELEASE ?= $(RELEASE)
37+
COUCH_RELEASE ?= $(RELEASE)
3738
FABRIC_RELEASE ?= $(RELEASE)
3839
DOCKER_NS ?= hyperledger
3940
TLS ?= true
@@ -116,6 +117,7 @@ build/docker-compose.yaml: compose/docker-compose.yaml.in
116117
| sed -e 's/_TLS_ENABLED_/${TLS}/g' \
117118
| sed -e 's/_DOCKER_NS_/${DOCKER_NS}/g' \
118119
| sed -e 's/_CA_RELEASE_/${CA_RELEASE}/g' \
120+
| sed -e 's/_COUCH_RELEASE_/${COUCH_RELEASE}/g' \
119121
| sed -e 's/_FABRIC_RELEASE_/${FABRIC_RELEASE}/g' \
120122
> $@
121123

examples/cluster/compose/docker-compose.yaml.in

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6-
version: '2'
6+
version: '2.1'
77

88
services:
99

@@ -45,9 +45,21 @@ services:
4545
depends_on:
4646
- ca
4747

48+
couchdb-base:
49+
image: _DOCKER_NS_/fabric-couchdb:_COUCH_RELEASE_
50+
logging:
51+
<<: *logging
52+
healthcheck:
53+
test: ["CMD", "curl", "-f", "http://localhost:5984"]
54+
interval: 10s
55+
timeout: 10s
56+
retries: 10
57+
4858
peer-base:
4959
image: _DOCKER_NS_/fabric-peer:_FABRIC_RELEASE_
5060
dns_search: .
61+
logging:
62+
<<: *logging
5163
environment:
5264
- CORE_PEER_TLS_ENABLED=_TLS_ENABLED_
5365
- CORE_LOGGING_LEVEL=WARNING
@@ -57,6 +69,11 @@ services:
5769
- /var/run/docker.sock:/var/run/docker.sock
5870
command: peer node start
5971

72+
couchdb1:
73+
container_name: couchdb1
74+
extends:
75+
service: couchdb-base
76+
6077
peer1:
6178
container_name: peer1
6279
extends:
@@ -66,12 +83,19 @@ services:
6683
- CORE_PEER_ADDRESS=peer1:7051
6784
- CORE_PEER_GOSSIP_ENDPOINT=peer1:7051
6885
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.net:7051
69-
logging:
70-
<<: *logging
86+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
7187
volumes:
7288
- ./nodes/peer1:/etc/hyperledger/fabric
7389
depends_on:
74-
- orderer
90+
orderer:
91+
condition: service_started
92+
couchdb1:
93+
condition: service_healthy
94+
95+
couchdb2:
96+
container_name: couchdb2
97+
extends:
98+
service: couchdb-base
7599

76100
peer2:
77101
container_name: peer2
@@ -82,13 +106,21 @@ services:
82106
- CORE_PEER_ADDRESS=peer2:7051
83107
- CORE_PEER_GOSSIP_ENDPOINT=peer2:7051
84108
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer2.org1.net:7051
85-
logging:
86-
<<: *logging
109+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
87110
volumes:
88111
- ./nodes/peer2:/etc/hyperledger/fabric
89112
depends_on:
90-
- orderer
91-
- peer1
113+
orderer:
114+
condition: service_started
115+
peer1:
116+
condition: service_started
117+
couchdb2:
118+
condition: service_healthy
119+
120+
couchdb3:
121+
container_name: couchdb3
122+
extends:
123+
service: couchdb-base
92124

93125
peer3:
94126
container_name: peer3
@@ -99,13 +131,21 @@ services:
99131
- CORE_PEER_ADDRESS=peer3:7051
100132
- CORE_PEER_GOSSIP_ENDPOINT=peer3:7051
101133
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer3.org1.net:7051
102-
logging:
103-
<<: *logging
134+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
104135
volumes:
105136
- ./nodes/peer3:/etc/hyperledger/fabric
106137
depends_on:
107-
- orderer
108-
- peer1
138+
orderer:
139+
condition: service_started
140+
peer1:
141+
condition: service_started
142+
couchdb3:
143+
condition: service_healthy
144+
145+
couchdb4:
146+
container_name: couchdb4
147+
extends:
148+
service: couchdb-base
109149

110150
peer4:
111151
container_name: peer4
@@ -116,13 +156,16 @@ services:
116156
- CORE_PEER_ADDRESS=peer4:7051
117157
- CORE_PEER_GOSSIP_ENDPOINT=peer4:7051
118158
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer4.org1.net:7051
119-
logging:
120-
<<: *logging
159+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb4:5984
121160
volumes:
122161
- ./nodes/peer4:/etc/hyperledger/fabric
123162
depends_on:
124-
- orderer
125-
- peer1
163+
orderer:
164+
condition: service_started
165+
peer1:
166+
condition: service_started
167+
couchdb4:
168+
condition: service_healthy
126169

127170
cli:
128171
image: _DOCKER_NS_/fabric-peer:_FABRIC_RELEASE_

examples/cluster/config/core.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,28 @@ ledger:
396396
# stateDatabase - options are "goleveldb", "CouchDB"
397397
# goleveldb - default state database stored in goleveldb.
398398
# CouchDB - store state database in CouchDB
399-
stateDatabase: goleveldb
399+
stateDatabase: CouchDB
400400
couchDBConfig:
401+
# It is recommended to run CouchDB on the same server as the peer, and
402+
# not map the CouchDB container port to a server port in docker-compose.
403+
# Otherwise proper security must be provided on the connection between
404+
# CouchDB client (on the peer) and server.
401405
couchDBAddress: 127.0.0.1:5984
406+
# This username must have read and write authority on CouchDB
402407
username:
408+
# The password is recommended to pass as an environment variable
409+
# during start up (eg LEDGER_COUCHDBCONFIG_PASSWORD).
410+
# If it is stored here, the file must be access control protected
411+
# to prevent unintended users from discovering the password.
403412
password:
413+
# Number of retries for CouchDB errors
414+
maxRetries: 3
415+
# Number of retries for CouchDB errors during peer startup
416+
maxRetriesOnStartup: 10
417+
# CouchDB request timeout (unit: duration, e.g. 20s)
418+
requestTimeout: 35s
419+
# Limit on the number of records to return per query
420+
queryLimit: 10000
404421

405422
# historyDatabase - options are true or false
406423
# Indicates if the history of key updates should be stored in goleveldb

0 commit comments

Comments
 (0)