mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Merge "[FAB-8540] Add ledger persistance to first-network" into release
This commit is contained in:
commit
e91eccfe45
2 changed files with 53 additions and 4 deletions
|
|
@ -48,6 +48,7 @@ function printHelp () {
|
|||
echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
|
||||
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
|
||||
echo " -i <imagetag> - pass the image tag to launch the network using the tag: 1.0.1, 1.0.2, 1.0.3, 1.0.4 (defaults to latest)"
|
||||
echo " -p - persist the ledgers of the containers to the ./ledgers/<container> directory"
|
||||
echo
|
||||
echo "Typically, one would first generate the required certificates and "
|
||||
echo "genesis block, then bring up the network. e.g.:"
|
||||
|
|
@ -112,10 +113,20 @@ function networkUp () {
|
|||
replacePrivateKey
|
||||
generateChannelArtifacts
|
||||
fi
|
||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
if $PERSIST ; then
|
||||
echo "Persisting ledgers to ./ledgers/"
|
||||
mkdir -p ./ledgers/
|
||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
else
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST up -d 2>&1
|
||||
fi
|
||||
else
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||
else
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR !!!! Unable to start network"
|
||||
|
|
@ -131,6 +142,8 @@ function networkDown () {
|
|||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
|
||||
# Don't remove containers, images, etc if restarting
|
||||
if [ "$MODE" != "restart" ]; then
|
||||
#Delete any persisted ledgers
|
||||
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers
|
||||
#Cleanup the chaincode containers
|
||||
clearContainers
|
||||
#Cleanup images
|
||||
|
|
@ -318,8 +331,11 @@ COMPOSE_FILE=docker-compose-cli.yaml
|
|||
COMPOSE_FILE_COUCH=docker-compose-couch.yaml
|
||||
# default image tag
|
||||
IMAGETAG="latest"
|
||||
# By default, to not use volume mounts for the ledgers
|
||||
PERSIST="false"
|
||||
COMPOSE_FILE_PERSIST=docker-compose-persist.yaml
|
||||
# Parse commandline args
|
||||
while getopts "h?m:c:t:d:f:s:i:" opt; do
|
||||
while getopts "h?m:c:t:d:f:s:i:p" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
printHelp
|
||||
|
|
@ -339,6 +355,8 @@ while getopts "h?m:c:t:d:f:s:i:" opt; do
|
|||
;;
|
||||
i) IMAGETAG=`uname -m`"-"$OPTARG
|
||||
;;
|
||||
p) PERSIST=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
31
first-network/docker-compose-persist.yaml
Normal file
31
first-network/docker-compose-persist.yaml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright IBM Corp. All Rights Reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
version: '2'
|
||||
|
||||
networks:
|
||||
byfn:
|
||||
|
||||
services:
|
||||
|
||||
orderer.example.com:
|
||||
volumes:
|
||||
- ./ledgers/orderer.example.com:/var/hyperledger/production/orderer
|
||||
|
||||
peer0.org1.example.com:
|
||||
volumes:
|
||||
- ./ledgers/peer0.org1.example.com:/var/hyperledger/production
|
||||
|
||||
peer1.org1.example.com:
|
||||
volumes:
|
||||
- ./ledgers/peer1.org1.example.com:/var/hyperledger/production
|
||||
|
||||
peer0.org2.example.com:
|
||||
volumes:
|
||||
- ./ledgers/peer0.org2.example.com:/var/hyperledger/production
|
||||
|
||||
peer1.org2.example.com:
|
||||
volumes:
|
||||
- ./ledgers/peer1.org2.example.com:/var/hyperledger/production
|
||||
Loading…
Reference in a new issue