Skip to content

Commit

Permalink
[FAB-5579] Add support for couchdb to examples/cluster
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ghaskins authored and mastersingh24 committed Sep 13, 2017
1 parent 73693f7 commit 0217469
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 17 deletions.
2 changes: 2 additions & 0 deletions examples/cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mspmap.cli := $(USERS_PATH)/Admin@org1.net

RELEASE ?= latest
CA_RELEASE ?= $(RELEASE)
COUCH_RELEASE ?= $(RELEASE)
FABRIC_RELEASE ?= $(RELEASE)
DOCKER_NS ?= hyperledger
TLS ?= true
Expand Down Expand Up @@ -116,6 +117,7 @@ build/docker-compose.yaml: compose/docker-compose.yaml.in
| sed -e 's/_TLS_ENABLED_/${TLS}/g' \
| sed -e 's/_DOCKER_NS_/${DOCKER_NS}/g' \
| sed -e 's/_CA_RELEASE_/${CA_RELEASE}/g' \
| sed -e 's/_COUCH_RELEASE_/${COUCH_RELEASE}/g' \
| sed -e 's/_FABRIC_RELEASE_/${FABRIC_RELEASE}/g' \
> $@

Expand Down
75 changes: 59 additions & 16 deletions examples/cluster/compose/docker-compose.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
#

version: '2'
version: '2.1'

services:

Expand Down Expand Up @@ -45,9 +45,21 @@ services:
depends_on:
- ca

couchdb-base:
image: _DOCKER_NS_/fabric-couchdb:_COUCH_RELEASE_
logging:
<<: *logging
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5984"]
interval: 10s
timeout: 10s
retries: 10

peer-base:
image: _DOCKER_NS_/fabric-peer:_FABRIC_RELEASE_
dns_search: .
logging:
<<: *logging
environment:
- CORE_PEER_TLS_ENABLED=_TLS_ENABLED_
- CORE_LOGGING_LEVEL=WARNING
Expand All @@ -57,6 +69,11 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
command: peer node start

couchdb1:
container_name: couchdb1
extends:
service: couchdb-base

peer1:
container_name: peer1
extends:
Expand All @@ -66,12 +83,19 @@ services:
- CORE_PEER_ADDRESS=peer1:7051
- CORE_PEER_GOSSIP_ENDPOINT=peer1:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.net:7051
logging:
<<: *logging
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
volumes:
- ./nodes/peer1:/etc/hyperledger/fabric
depends_on:
- orderer
orderer:
condition: service_started
couchdb1:
condition: service_healthy

couchdb2:
container_name: couchdb2
extends:
service: couchdb-base

peer2:
container_name: peer2
Expand All @@ -82,13 +106,21 @@ services:
- CORE_PEER_ADDRESS=peer2:7051
- CORE_PEER_GOSSIP_ENDPOINT=peer2:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer2.org1.net:7051
logging:
<<: *logging
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
volumes:
- ./nodes/peer2:/etc/hyperledger/fabric
depends_on:
- orderer
- peer1
orderer:
condition: service_started
peer1:
condition: service_started
couchdb2:
condition: service_healthy

couchdb3:
container_name: couchdb3
extends:
service: couchdb-base

peer3:
container_name: peer3
Expand All @@ -99,13 +131,21 @@ services:
- CORE_PEER_ADDRESS=peer3:7051
- CORE_PEER_GOSSIP_ENDPOINT=peer3:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer3.org1.net:7051
logging:
<<: *logging
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
volumes:
- ./nodes/peer3:/etc/hyperledger/fabric
depends_on:
- orderer
- peer1
orderer:
condition: service_started
peer1:
condition: service_started
couchdb3:
condition: service_healthy

couchdb4:
container_name: couchdb4
extends:
service: couchdb-base

peer4:
container_name: peer4
Expand All @@ -116,13 +156,16 @@ services:
- CORE_PEER_ADDRESS=peer4:7051
- CORE_PEER_GOSSIP_ENDPOINT=peer4:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer4.org1.net:7051
logging:
<<: *logging
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb4:5984
volumes:
- ./nodes/peer4:/etc/hyperledger/fabric
depends_on:
- orderer
- peer1
orderer:
condition: service_started
peer1:
condition: service_started
couchdb4:
condition: service_healthy

cli:
image: _DOCKER_NS_/fabric-peer:_FABRIC_RELEASE_
Expand Down
19 changes: 18 additions & 1 deletion examples/cluster/config/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,28 @@ ledger:
# stateDatabase - options are "goleveldb", "CouchDB"
# goleveldb - default state database stored in goleveldb.
# CouchDB - store state database in CouchDB
stateDatabase: goleveldb
stateDatabase: CouchDB
couchDBConfig:
# It is recommended to run CouchDB on the same server as the peer, and
# not map the CouchDB container port to a server port in docker-compose.
# Otherwise proper security must be provided on the connection between
# CouchDB client (on the peer) and server.
couchDBAddress: 127.0.0.1:5984
# This username must have read and write authority on CouchDB
username:
# The password is recommended to pass as an environment variable
# during start up (eg LEDGER_COUCHDBCONFIG_PASSWORD).
# If it is stored here, the file must be access control protected
# to prevent unintended users from discovering the password.
password:
# Number of retries for CouchDB errors
maxRetries: 3
# Number of retries for CouchDB errors during peer startup
maxRetriesOnStartup: 10
# CouchDB request timeout (unit: duration, e.g. 20s)
requestTimeout: 35s
# Limit on the number of records to return per query
queryLimit: 10000

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

0 comments on commit 0217469

Please sign in to comment.