Skip to content

Commit 4f2cd8d

Browse files
suryalnvsJason Yellick
authored and
Jason Yellick
committed
[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 <suryalnvs@gmail.com> Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent e4a0666 commit 4f2cd8d

8 files changed

+28
-16
lines changed

first-network/.env

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
COMPOSE_PROJECT_NAME=net
2+
IMAGE_TAG=latest

first-network/base/docker-compose-base.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99

1010
orderer.example.com:
1111
container_name: orderer.example.com
12-
image: hyperledger/fabric-orderer
12+
image: hyperledger/fabric-orderer:$IMAGE_TAG
1313
environment:
1414
- ORDERER_GENERAL_LOGLEVEL=debug
1515
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0

first-network/base/peer-base.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version: '2'
77

88
services:
99
peer-base:
10-
image: hyperledger/fabric-peer
10+
image: hyperledger/fabric-peer:$IMAGE_TAG
1111
environment:
1212
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
1313
# the following setting starts chaincode containers on the same

first-network/byfn.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export FABRIC_CFG_PATH=${PWD}
3434
# Print the usage message
3535
function printHelp () {
3636
echo "Usage: "
37-
echo " byfn.sh up|down|restart|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]"
37+
echo " byfn.sh up|down|restart|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-i <imagetag>]"
3838
echo " byfn.sh -h|--help (print this message)"
3939
echo " <mode> - one of 'up', 'down', 'restart' or 'generate'"
4040
echo " - 'up' - bring up the network with docker-compose up"
@@ -47,12 +47,14 @@ function printHelp () {
4747
echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
4848
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
4949
echo " -l <language> - the chaincode language: golang (default) or node"
50+
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
5051
echo
5152
echo "Typically, one would first generate the required certificates and "
5253
echo "genesis block, then bring up the network. e.g.:"
5354
echo
5455
echo " byfn.sh generate -c mychannel"
5556
echo " byfn.sh up -c mychannel -s couchdb"
57+
echo " byfn.sh up -c mychannel -s couchdb -i 1.1.0-alpha"
5658
echo " byfn.sh up -l node"
5759
echo " byfn.sh down -c mychannel"
5860
echo
@@ -112,9 +114,9 @@ function networkUp () {
112114
generateChannelArtifacts
113115
fi
114116
if [ "${IF_COUCHDB}" == "couchdb" ]; then
115-
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
117+
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
116118
else
117-
docker-compose -f $COMPOSE_FILE up -d 2>&1
119+
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
118120
fi
119121
if [ $? -ne 0 ]; then
120122
echo "ERROR !!!! Unable to start network"
@@ -322,6 +324,8 @@ COMPOSE_FILE=docker-compose-cli.yaml
322324
COMPOSE_FILE_COUCH=docker-compose-couch.yaml
323325
# use golang as the default language for chaincode
324326
LANGUAGE=golang
327+
# default image tag
328+
IMAGETAG="latest"
325329
# Parse commandline args
326330
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
327331
shift
@@ -341,7 +345,7 @@ else
341345
exit 1
342346
fi
343347

344-
while getopts "h?c:t:d:f:s:l:" opt; do
348+
while getopts "h?c:t:d:f:s:l:i:" opt; do
345349
case "$opt" in
346350
h|\?)
347351
printHelp
@@ -359,6 +363,8 @@ while getopts "h?c:t:d:f:s:l:" opt; do
359363
;;
360364
l) LANGUAGE=$OPTARG
361365
;;
366+
i) IMAGETAG=`uname -m`"-"$OPTARG
367+
;;
362368
esac
363369
done
364370

first-network/docker-compose-cli.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ services:
5252

5353
cli:
5454
container_name: cli
55-
image: hyperledger/fabric-tools
55+
image: hyperledger/fabric-tools:$IMAGE_TAG
5656
tty: true
5757
environment:
5858
- GOPATH=/opt/gopath

first-network/docker-compose-couch.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ networks:
1111
services:
1212
couchdb0:
1313
container_name: couchdb0
14-
image: hyperledger/fabric-couchdb
14+
image: hyperledger/fabric-couchdb:$IMAGE_TAG
1515
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
1616
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
1717
environment:
@@ -38,7 +38,7 @@ services:
3838

3939
couchdb1:
4040
container_name: couchdb1
41-
image: hyperledger/fabric-couchdb
41+
image: hyperledger/fabric-couchdb:$IMAGE_TAG
4242
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
4343
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
4444
environment:
@@ -65,7 +65,7 @@ services:
6565

6666
couchdb2:
6767
container_name: couchdb2
68-
image: hyperledger/fabric-couchdb
68+
image: hyperledger/fabric-couchdb:$IMAGE_TAG
6969
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
7070
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
7171
environment:
@@ -92,7 +92,7 @@ services:
9292

9393
couchdb3:
9494
container_name: couchdb3
95-
image: hyperledger/fabric-couchdb
95+
image: hyperledger/fabric-couchdb:$IMAGE_TAG
9696
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
9797
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
9898
environment:

first-network/docker-compose-e2e-template.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ networks:
99
byfn:
1010
services:
1111
ca0:
12-
image: hyperledger/fabric-ca
12+
image: hyperledger/fabric-ca:$IMAGE_TAG
1313
environment:
1414
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
1515
- FABRIC_CA_SERVER_CA_NAME=ca-org1
@@ -26,7 +26,7 @@ services:
2626
- byfn
2727

2828
ca1:
29-
image: hyperledger/fabric-ca
29+
image: hyperledger/fabric-ca:$IMAGE_TAG
3030
environment:
3131
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
3232
- FABRIC_CA_SERVER_CA_NAME=ca-org2

first-network/eyfn.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function printHelp () {
3131
echo " -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)"
3232
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
3333
echo " -l <language> - the chaincode language: golang (default) or node"
34+
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
3435
echo
3536
echo "Typically, one would first generate the required certificates and "
3637
echo "genesis block, then bring up the network. e.g.:"
@@ -97,9 +98,9 @@ function networkUp () {
9798
fi
9899
# start org3 peers
99100
if [ "${IF_COUCHDB}" == "couchdb" ]; then
100-
docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1
101+
IMAGE_TAG=${IMAGETAG} docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1
101102
else
102-
docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
103+
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
103104
fi
104105
if [ $? -ne 0 ]; then
105106
echo "ERROR !!!! Unable to start Org3 network"
@@ -241,6 +242,8 @@ COMPOSE_FILE_ORG3=docker-compose-org3.yaml
241242
COMPOSE_FILE_COUCH_ORG3=docker-compose-couch-org3.yaml
242243
# use golang as the default language for chaincode
243244
LANGUAGE=golang
245+
# default image tag
246+
IMAGETAG="latest"
244247

245248
# Parse commandline args
246249
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
@@ -260,7 +263,7 @@ else
260263
printHelp
261264
exit 1
262265
fi
263-
while getopts "h?c:t:d:f:s:l:" opt; do
266+
while getopts "h?c:t:d:f:s:l:i:" opt; do
264267
case "$opt" in
265268
h|\?)
266269
printHelp
@@ -278,6 +281,8 @@ while getopts "h?c:t:d:f:s:l:" opt; do
278281
;;
279282
l) LANGUAGE=$OPTARG
280283
;;
284+
i) IMAGETAG=$OPTARG
285+
;;
281286
esac
282287
done
283288

0 commit comments

Comments
 (0)