From 4f2cd8d4ac2315c393deb001f7b5b9ffd17db01f Mon Sep 17 00:00:00 2001 From: Surya Date: Wed, 21 Feb 2018 18:16:03 -0500 Subject: [PATCH] [FAB-8445] Adding IMAGE_TAG option to byfn Adding IMAGE_TAG option to byfn script to launch specific version of fabric network Usage: ./byfn.sh up -i 1.1.0-alpha Change-Id: I67a1d01257abd7021ea344c354c6e1c97eebf4f7 Signed-off-by: Surya Signed-off-by: Jason Yellick --- first-network/.env | 1 + first-network/base/docker-compose-base.yaml | 2 +- first-network/base/peer-base.yaml | 2 +- first-network/byfn.sh | 14 ++++++++++---- first-network/docker-compose-cli.yaml | 2 +- first-network/docker-compose-couch.yaml | 8 ++++---- first-network/docker-compose-e2e-template.yaml | 4 ++-- first-network/eyfn.sh | 11 ++++++++--- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/first-network/.env b/first-network/.env index 4fd2ee0d73..a6665fed28 100644 --- a/first-network/.env +++ b/first-network/.env @@ -1 +1,2 @@ COMPOSE_PROJECT_NAME=net +IMAGE_TAG=latest diff --git a/first-network/base/docker-compose-base.yaml b/first-network/base/docker-compose-base.yaml index d31c964532..4acacc7cbd 100644 --- a/first-network/base/docker-compose-base.yaml +++ b/first-network/base/docker-compose-base.yaml @@ -9,7 +9,7 @@ services: orderer.example.com: container_name: orderer.example.com - image: hyperledger/fabric-orderer + image: hyperledger/fabric-orderer:$IMAGE_TAG environment: - ORDERER_GENERAL_LOGLEVEL=debug - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 diff --git a/first-network/base/peer-base.yaml b/first-network/base/peer-base.yaml index 3063386f30..063001f601 100644 --- a/first-network/base/peer-base.yaml +++ b/first-network/base/peer-base.yaml @@ -7,7 +7,7 @@ version: '2' services: peer-base: - image: hyperledger/fabric-peer + image: hyperledger/fabric-peer:$IMAGE_TAG environment: - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock # the following setting starts chaincode containers on the same diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 6d2c16be38..172f96d587 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -34,7 +34,7 @@ export FABRIC_CFG_PATH=${PWD} # Print the usage message function printHelp () { echo "Usage: " - echo " byfn.sh up|down|restart|generate [-c ] [-t ] [-d ] [-f ] [-s ]" + echo " byfn.sh up|down|restart|generate [-c ] [-t ] [-d ] [-f ] [-s ] [-i ]" echo " byfn.sh -h|--help (print this message)" echo " - one of 'up', 'down', 'restart' or 'generate'" echo " - 'up' - bring up the network with docker-compose up" @@ -47,12 +47,14 @@ function printHelp () { echo " -f - specify which docker-compose file use (defaults to docker-compose-cli.yaml)" echo " -s - the database backend to use: goleveldb (default) or couchdb" echo " -l - the chaincode language: golang (default) or node" + echo " -i - the tag to be used to launch the network (defaults to \"latest\")" echo echo "Typically, one would first generate the required certificates and " echo "genesis block, then bring up the network. e.g.:" echo echo " byfn.sh generate -c mychannel" echo " byfn.sh up -c mychannel -s couchdb" + echo " byfn.sh up -c mychannel -s couchdb -i 1.1.0-alpha" echo " byfn.sh up -l node" echo " byfn.sh down -c mychannel" echo @@ -112,9 +114,9 @@ function networkUp () { generateChannelArtifacts fi if [ "${IF_COUCHDB}" == "couchdb" ]; then - docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 + IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 else - docker-compose -f $COMPOSE_FILE up -d 2>&1 + IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1 fi if [ $? -ne 0 ]; then echo "ERROR !!!! Unable to start network" @@ -322,6 +324,8 @@ COMPOSE_FILE=docker-compose-cli.yaml COMPOSE_FILE_COUCH=docker-compose-couch.yaml # use golang as the default language for chaincode LANGUAGE=golang +# default image tag +IMAGETAG="latest" # Parse commandline args if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful! shift @@ -341,7 +345,7 @@ else exit 1 fi -while getopts "h?c:t:d:f:s:l:" opt; do +while getopts "h?c:t:d:f:s:l:i:" opt; do case "$opt" in h|\?) printHelp @@ -359,6 +363,8 @@ while getopts "h?c:t:d:f:s:l:" opt; do ;; l) LANGUAGE=$OPTARG ;; + i) IMAGETAG=`uname -m`"-"$OPTARG + ;; esac done diff --git a/first-network/docker-compose-cli.yaml b/first-network/docker-compose-cli.yaml index 30ad3f36f3..44e45f5d49 100644 --- a/first-network/docker-compose-cli.yaml +++ b/first-network/docker-compose-cli.yaml @@ -52,7 +52,7 @@ services: cli: container_name: cli - image: hyperledger/fabric-tools + image: hyperledger/fabric-tools:$IMAGE_TAG tty: true environment: - GOPATH=/opt/gopath diff --git a/first-network/docker-compose-couch.yaml b/first-network/docker-compose-couch.yaml index b14c7f5ca9..992031917a 100644 --- a/first-network/docker-compose-couch.yaml +++ b/first-network/docker-compose-couch.yaml @@ -11,7 +11,7 @@ networks: services: couchdb0: container_name: couchdb0 - image: hyperledger/fabric-couchdb + image: hyperledger/fabric-couchdb:$IMAGE_TAG # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: @@ -38,7 +38,7 @@ services: couchdb1: container_name: couchdb1 - image: hyperledger/fabric-couchdb + image: hyperledger/fabric-couchdb:$IMAGE_TAG # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: @@ -65,7 +65,7 @@ services: couchdb2: container_name: couchdb2 - image: hyperledger/fabric-couchdb + image: hyperledger/fabric-couchdb:$IMAGE_TAG # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: @@ -92,7 +92,7 @@ services: couchdb3: container_name: couchdb3 - image: hyperledger/fabric-couchdb + image: hyperledger/fabric-couchdb:$IMAGE_TAG # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: diff --git a/first-network/docker-compose-e2e-template.yaml b/first-network/docker-compose-e2e-template.yaml index def9b16dac..650b9651cf 100644 --- a/first-network/docker-compose-e2e-template.yaml +++ b/first-network/docker-compose-e2e-template.yaml @@ -9,7 +9,7 @@ networks: byfn: services: ca0: - image: hyperledger/fabric-ca + image: hyperledger/fabric-ca:$IMAGE_TAG environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca-org1 @@ -26,7 +26,7 @@ services: - byfn ca1: - image: hyperledger/fabric-ca + image: hyperledger/fabric-ca:$IMAGE_TAG environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca-org2 diff --git a/first-network/eyfn.sh b/first-network/eyfn.sh index e89abfcbb9..1d0bf090fc 100755 --- a/first-network/eyfn.sh +++ b/first-network/eyfn.sh @@ -31,6 +31,7 @@ function printHelp () { echo " -f - specify which docker-compose file use (defaults to docker-compose-cli.yaml)" echo " -s - the database backend to use: goleveldb (default) or couchdb" echo " -l - the chaincode language: golang (default) or node" + echo " -i - the tag to be used to launch the network (defaults to \"latest\")" echo echo "Typically, one would first generate the required certificates and " echo "genesis block, then bring up the network. e.g.:" @@ -97,9 +98,9 @@ function networkUp () { fi # start org3 peers if [ "${IF_COUCHDB}" == "couchdb" ]; then - docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1 + IMAGE_TAG=${IMAGETAG} docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1 else - docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 + IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 fi if [ $? -ne 0 ]; then echo "ERROR !!!! Unable to start Org3 network" @@ -241,6 +242,8 @@ COMPOSE_FILE_ORG3=docker-compose-org3.yaml COMPOSE_FILE_COUCH_ORG3=docker-compose-couch-org3.yaml # use golang as the default language for chaincode LANGUAGE=golang +# default image tag +IMAGETAG="latest" # Parse commandline args if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful! @@ -260,7 +263,7 @@ else printHelp exit 1 fi -while getopts "h?c:t:d:f:s:l:" opt; do +while getopts "h?c:t:d:f:s:l:i:" opt; do case "$opt" in h|\?) printHelp @@ -278,6 +281,8 @@ while getopts "h?c:t:d:f:s:l:" opt; do ;; l) LANGUAGE=$OPTARG ;; + i) IMAGETAG=$OPTARG + ;; esac done