mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
[FAB-8567] Alt: Always use volumes for ledger (r)
Docker compose makes volume management easy and transparent to the user. By defaulting the ledgers to be docker compose volumes, we transparently get ledger persistence for the ugprade case, and may trivially tear the volumes down in the docker-compose down command with the addition of the --volumes flag. This would allow the upgrade scenario to work without the use of the '-p' flag, and is likely to be generally much cleaner. Change-Id: Id008d50487e8d304d6e2517300402dfd1cc8c0c3 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
This commit is contained in:
parent
e91eccfe45
commit
5271be875e
4 changed files with 20 additions and 56 deletions
|
|
@ -28,6 +28,7 @@ services:
|
|||
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
|
||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
|
||||
- orderer.example.com:/var/hyperledger/production/orderer
|
||||
ports:
|
||||
- 7050:7050
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ services:
|
|||
- /var/run/:/host/var/run/
|
||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
|
||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
||||
- peer0.org1.example.com:/var/hyperledger/production
|
||||
ports:
|
||||
- 7051:7051
|
||||
- 7053:7053
|
||||
|
|
@ -64,6 +66,7 @@ services:
|
|||
- /var/run/:/host/var/run/
|
||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
|
||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
||||
- peer1.org1.example.com:/var/hyperledger/production
|
||||
|
||||
ports:
|
||||
- 8051:7051
|
||||
|
|
@ -84,6 +87,7 @@ services:
|
|||
- /var/run/:/host/var/run/
|
||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
|
||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
||||
- peer0.org2.example.com:/var/hyperledger/production
|
||||
ports:
|
||||
- 9051:7051
|
||||
- 9053:7053
|
||||
|
|
@ -103,6 +107,7 @@ services:
|
|||
- /var/run/:/host/var/run/
|
||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
|
||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
||||
- peer1.org2.example.com:/var/hyperledger/production
|
||||
ports:
|
||||
- 10051:7051
|
||||
- 10053:7053
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ 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.:"
|
||||
|
|
@ -113,20 +112,10 @@ function networkUp () {
|
|||
replacePrivateKey
|
||||
generateChannelArtifacts
|
||||
fi
|
||||
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
|
||||
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
|
||||
else
|
||||
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
|
||||
IMAGE_TAG=$IMAGETAG CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR !!!! Unable to start network"
|
||||
|
|
@ -138,12 +127,11 @@ function networkUp () {
|
|||
|
||||
# Tear down running network
|
||||
function networkDown () {
|
||||
docker-compose -f $COMPOSE_FILE down
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
|
||||
# Don't remove containers, images, etc if restarting
|
||||
docker-compose -f $COMPOSE_FILE down --volumes
|
||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down --volumes
|
||||
# Don't remove the generated artifacts -- note, the ledgers are always removed
|
||||
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
|
||||
# Bring the containers down deleting their volumes
|
||||
#Cleanup the chaincode containers
|
||||
clearContainers
|
||||
#Cleanup images
|
||||
|
|
@ -331,11 +319,8 @@ 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:p" opt; do
|
||||
while getopts "h?m:c:t:d:f:s:i:" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
printHelp
|
||||
|
|
@ -355,8 +340,6 @@ while getopts "h?m:c:t:d:f:s:i:p" opt; do
|
|||
;;
|
||||
i) IMAGETAG=`uname -m`"-"$OPTARG
|
||||
;;
|
||||
p) PERSIST=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@
|
|||
|
||||
version: '2'
|
||||
|
||||
volumes:
|
||||
orderer.example.com:
|
||||
peer0.org1.example.com:
|
||||
peer1.org1.example.com:
|
||||
peer0.org2.example.com:
|
||||
peer1.org2.example.com:
|
||||
|
||||
networks:
|
||||
byfn:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# 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