9
9
# This script builds the docker compose file needed to run this sample.
10
10
#
11
11
12
+ # IMPORTANT: The following default FABRIC_TAG value should be updated for each
13
+ # release after the fabric-orderer and fabric-peer images have been published
14
+ # for the release.
15
+ export FABRIC_TAG=${FABRIC_TAG:- 1.2.0}
16
+
17
+ export FABRIC_CA_TAG=${FABRIC_CA_TAG:- ${FABRIC_TAG} }
18
+ export NS=${NS:- hyperledger}
19
+
20
+ export ARCH=" linux-amd64" # Docker images run on linux
21
+ CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH} -${FABRIC_CA_TAG} .tar.gz
22
+ URL=https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH} -${FABRIC_CA_TAG} /${CA_BINARY_FILE}
23
+
12
24
SDIR=$( dirname " $0 " )
13
25
source $SDIR /scripts/env.sh
14
26
15
27
function main {
16
28
{
29
+ createDockerFiles
17
30
writeHeader
18
31
writeRootFabricCA
19
32
if $USE_INTERMEDIATE_CA ; then
@@ -26,6 +39,41 @@ function main {
26
39
log " Created docker-compose.yml"
27
40
}
28
41
42
+ # Create various dockerfiles used by this sample
43
+ function createDockerFiles {
44
+ if [ " $FABRIC_TAG " = " local" ]; then
45
+ ORDERER_BUILD=" image: hyperledger/fabric-ca-orderer"
46
+ PEER_BUILD=" image: hyperledger/fabric-ca-peer"
47
+ TOOLS_BUILD=" image: hyperledger/fabric-ca-tools"
48
+ else
49
+ createDockerFile orderer
50
+ ORDERER_BUILD=" build:
51
+ context: .
52
+ dockerfile: fabric-ca-orderer.dockerfile"
53
+ createDockerFile peer
54
+ PEER_BUILD=" build:
55
+ context: .
56
+ dockerfile: fabric-ca-peer.dockerfile"
57
+ createDockerFile tools
58
+ TOOLS_BUILD=" build:
59
+ context: .
60
+ dockerfile: fabric-ca-tools.dockerfile"
61
+ fi
62
+ }
63
+
64
+ # createDockerFile
65
+ function createDockerFile {
66
+ {
67
+ echo " FROM ${NS} /fabric-${1} :${FABRIC_TAG} "
68
+ echo ' RUN apt-get update && apt-get install -y netcat jq && apt-get install -y curl && rm -rf /var/cache/apt'
69
+ echo " RUN curl -o /tmp/fabric-ca-client.tar.gz $URL && tar -xzvf /tmp/fabric-ca-client.tar.gz -C /tmp && cp /tmp/bin/fabric-ca-client /usr/local/bin"
70
+ echo ' RUN chmod +x /usr/local/bin/fabric-ca-client'
71
+ echo ' ARG FABRIC_CA_DYNAMIC_LINK=false'
72
+ # libraries needed when image is built dynamically
73
+ echo ' RUN if [ "\$FABRIC_CA_DYNAMIC_LINK" = "true" ]; then apt-get install -y libltdl-dev; fi'
74
+ } > $SDIR /fabric-ca-${1} .dockerfile
75
+ }
76
+
29
77
# Write services for the root fabric CA servers
30
78
function writeRootFabricCA {
31
79
for ORG in $ORGS ; do
@@ -46,7 +94,7 @@ function writeIntermediateFabricCA {
46
94
function writeSetupFabric {
47
95
echo " setup:
48
96
container_name: setup
49
- image: hyperledger/fabric-ca-tools
97
+ $TOOLS_BUILD
50
98
command: /bin/bash -c '/scripts/setup-fabric.sh 2>&1 | tee /$SETUP_LOGFILE ; sleep 99999'
51
99
volumes:
52
100
- ./scripts:/scripts
@@ -173,7 +221,7 @@ function writeOrderer {
173
221
MYHOME=/etc/hyperledger/orderer
174
222
echo " $ORDERER_NAME :
175
223
container_name: $ORDERER_NAME
176
- image: hyperledger/fabric-ca-orderer
224
+ $ORDERER_BUILD
177
225
environment:
178
226
- FABRIC_CA_CLIENT_HOME=$MYHOME
179
227
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
@@ -210,7 +258,7 @@ function writePeer {
210
258
MYHOME=/opt/gopath/src/github.com/hyperledger/fabric/peer
211
259
echo " $PEER_NAME :
212
260
container_name: $PEER_NAME
213
- image: hyperledger/fabric-ca-peer
261
+ $PEER_BUILD
214
262
environment:
215
263
- FABRIC_CA_CLIENT_HOME=$MYHOME
216
264
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
0 commit comments