mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 09:35:10 +00:00
Merge "[FAB-8567] Alt: Always use volumes for ledger (m)"
This commit is contained in:
commit
d58a13682b
6 changed files with 38 additions and 65 deletions
|
|
@ -28,6 +28,7 @@ services:
|
||||||
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
|
- ../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/msp:/var/hyperledger/orderer/msp
|
||||||
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
|
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
|
||||||
|
- orderer.example.com:/var/hyperledger/production/orderer
|
||||||
ports:
|
ports:
|
||||||
- 7050:7050
|
- 7050:7050
|
||||||
|
|
||||||
|
|
@ -46,6 +47,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /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/msp:/etc/hyperledger/fabric/msp
|
||||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer0.org1.example.com:/var/hyperledger/production
|
||||||
ports:
|
ports:
|
||||||
- 7051:7051
|
- 7051:7051
|
||||||
- 7053:7053
|
- 7053:7053
|
||||||
|
|
@ -65,6 +67,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /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/msp:/etc/hyperledger/fabric/msp
|
||||||
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer1.org1.example.com:/var/hyperledger/production
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- 8051:7051
|
- 8051:7051
|
||||||
|
|
@ -85,6 +88,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /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/msp:/etc/hyperledger/fabric/msp
|
||||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer0.org2.example.com:/var/hyperledger/production
|
||||||
ports:
|
ports:
|
||||||
- 9051:7051
|
- 9051:7051
|
||||||
- 9053:7053
|
- 9053:7053
|
||||||
|
|
@ -104,6 +108,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /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/msp:/etc/hyperledger/fabric/msp
|
||||||
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer1.org2.example.com:/var/hyperledger/production
|
||||||
ports:
|
ports:
|
||||||
- 10051:7051
|
- 10051:7051
|
||||||
- 10053:7053
|
- 10053:7053
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ function printHelp () {
|
||||||
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
|
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
|
||||||
echo " -l <language> - the chaincode language: golang (default) or node"
|
echo " -l <language> - the chaincode language: golang (default) or node"
|
||||||
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
|
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
|
||||||
echo " -p - persist the ledgers of the containers to the ./ledgers/<container> directory"
|
|
||||||
echo
|
echo
|
||||||
echo "Typically, one would first generate the required certificates and "
|
echo "Typically, one would first generate the required certificates and "
|
||||||
echo "genesis block, then bring up the network. e.g.:"
|
echo "genesis block, then bring up the network. e.g.:"
|
||||||
|
|
@ -154,20 +153,10 @@ function networkUp () {
|
||||||
replacePrivateKey
|
replacePrivateKey
|
||||||
generateChannelArtifacts
|
generateChannelArtifacts
|
||||||
fi
|
fi
|
||||||
if $PERSIST ; then
|
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||||
echo "Persisting ledgers to ./ledgers/"
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
||||||
mkdir -p ./ledgers/
|
else
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH up -d 2>&1
|
|
||||||
else
|
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST up -d 2>&1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
|
|
||||||
else
|
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR !!!! Unable to start network"
|
echo "ERROR !!!! Unable to start network"
|
||||||
|
|
@ -185,8 +174,9 @@ function networkUp () {
|
||||||
# Stop the orderer and peers, backup the ledger from orderer and peers, cleanup chaincode containers and images
|
# Stop the orderer and peers, backup the ledger from orderer and peers, cleanup chaincode containers and images
|
||||||
# and relaunch the orderer and peers with latest tag
|
# and relaunch the orderer and peers with latest tag
|
||||||
function upgradeNetwork () {
|
function upgradeNetwork () {
|
||||||
if [ ! -d ledgers ]; then
|
docker inspect -f '{{.Config.Volumes}}' orderer.example.com |grep -q '/var/hyperledger/production/orderer'
|
||||||
echo "ERROR !!!! There is no persisted ledgers directory, did you start your network with -p?"
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR !!!! This network does not appear to be using volumes for its ledgers, did you start from fabric-samples >= v1.0.6?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -197,9 +187,9 @@ function upgradeNetwork () {
|
||||||
|
|
||||||
export IMAGE_TAG=$IMAGETAG
|
export IMAGE_TAG=$IMAGETAG
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST -f $COMPOSE_FILE_COUCH"
|
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH"
|
||||||
else
|
else
|
||||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_PERSIST"
|
COMPOSE_FILES="-f $COMPOSE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# removing the cli container
|
# removing the cli container
|
||||||
|
|
@ -242,12 +232,12 @@ function upgradeNetwork () {
|
||||||
|
|
||||||
# Tear down running network
|
# Tear down running network
|
||||||
function networkDown () {
|
function networkDown () {
|
||||||
docker-compose -f $COMPOSE_FILE down
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down --volumes
|
||||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
|
docker-compose -f $COMPOSE_FILE down --volumes
|
||||||
# Don't remove containers, images, etc if restarting
|
# Don't remove the generated artifacts -- note, the ledgers are always removed
|
||||||
if [ "$MODE" != "restart" ]; then
|
if [ "$MODE" != "restart" ]; then
|
||||||
#Delete any persisted ledgers
|
# Bring down the network, deleting the volumes
|
||||||
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers
|
#Delete any ledger backups
|
||||||
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers-backup
|
docker run -v $PWD:/tmp/first-network --rm hyperledger/fabric-tools:$IMAGETAG rm -Rf /tmp/first-network/ledgers-backup
|
||||||
#Cleanup the chaincode containers
|
#Cleanup the chaincode containers
|
||||||
clearContainers
|
clearContainers
|
||||||
|
|
@ -439,9 +429,6 @@ COMPOSE_FILE_COUCH=docker-compose-couch.yaml
|
||||||
LANGUAGE=golang
|
LANGUAGE=golang
|
||||||
# default image tag
|
# default image tag
|
||||||
IMAGETAG="latest"
|
IMAGETAG="latest"
|
||||||
# By default, to not use volume mounts for the ledgers
|
|
||||||
PERSIST="false"
|
|
||||||
COMPOSE_FILE_PERSIST=docker-compose-persist.yaml
|
|
||||||
# Parse commandline args
|
# Parse commandline args
|
||||||
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
|
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
|
||||||
shift
|
shift
|
||||||
|
|
@ -463,7 +450,7 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts "h?m:c:t:d:f:s:l:i:p" opt; do
|
while getopts "h?m:c:t:d:f:s:l:i:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h|\?)
|
h|\?)
|
||||||
printHelp
|
printHelp
|
||||||
|
|
@ -483,8 +470,6 @@ while getopts "h?m:c:t:d:f:s:l:i:p" opt; do
|
||||||
;;
|
;;
|
||||||
i) IMAGETAG=`uname -m`"-"$OPTARG
|
i) IMAGETAG=`uname -m`"-"$OPTARG
|
||||||
;;
|
;;
|
||||||
p) PERSIST=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
|
|
||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
orderer.example.com:
|
||||||
|
peer0.org1.example.com:
|
||||||
|
peer1.org1.example.com:
|
||||||
|
peer0.org2.example.com:
|
||||||
|
peer1.org2.example.com:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
byfn:
|
byfn:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
peer0.org3.example.com:
|
||||||
|
peer1.org3.example.com:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
byfn:
|
byfn:
|
||||||
|
|
@ -25,6 +28,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /var/run/:/host/var/run/
|
||||||
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp
|
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp
|
||||||
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls
|
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer0.org3.example.com:/var/hyperledger/production
|
||||||
ports:
|
ports:
|
||||||
- 11051:7051
|
- 11051:7051
|
||||||
- 11053:7053
|
- 11053:7053
|
||||||
|
|
@ -46,6 +50,7 @@ services:
|
||||||
- /var/run/:/host/var/run/
|
- /var/run/:/host/var/run/
|
||||||
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp:/etc/hyperledger/fabric/msp
|
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp:/etc/hyperledger/fabric/msp
|
||||||
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls:/etc/hyperledger/fabric/tls
|
- ./org3-artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls:/etc/hyperledger/fabric/tls
|
||||||
|
- peer1.org3.example.com:/var/hyperledger/production
|
||||||
ports:
|
ports:
|
||||||
- 12051:7051
|
- 12051:7051
|
||||||
- 12053:7053
|
- 12053:7053
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -134,10 +134,8 @@ function networkUp () {
|
||||||
|
|
||||||
# Tear down running network
|
# Tear down running network
|
||||||
function networkDown () {
|
function networkDown () {
|
||||||
docker-compose -f $COMPOSE_FILE_ORG3 down
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 down --volumes
|
||||||
docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 down
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes
|
||||||
docker-compose -f $COMPOSE_FILE down
|
|
||||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
|
|
||||||
# Don't remove containers, images, etc if restarting
|
# Don't remove containers, images, etc if restarting
|
||||||
if [ "$MODE" != "restart" ]; then
|
if [ "$MODE" != "restart" ]; then
|
||||||
#Cleanup the chaincode containers
|
#Cleanup the chaincode containers
|
||||||
|
|
@ -149,6 +147,10 @@ function networkDown () {
|
||||||
# remove the docker-compose yaml file that was customized to the example
|
# remove the docker-compose yaml file that was customized to the example
|
||||||
rm -f docker-compose-e2e.yaml
|
rm -f docker-compose-e2e.yaml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# For some black-magic reason the first docker-compose down does not actually cleanup the volumes
|
||||||
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 down --volumes
|
||||||
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use the CLI container to create the configuration transaction needed to add
|
# Use the CLI container to create the configuration transaction needed to add
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue