mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 17:45:10 +00:00
Merge "[FABC-131] Change fabric-ca sample to build images"
This commit is contained in:
commit
634203d26f
5 changed files with 85 additions and 43 deletions
3
fabric-ca/.gitignore
vendored
3
fabric-ca/.gitignore
vendored
|
|
@ -1,2 +1,5 @@
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
|
fabric-ca-orderer.dockerfile
|
||||||
|
fabric-ca-peer.dockerfile
|
||||||
|
fabric-ca-tools.dockerfile
|
||||||
data
|
data
|
||||||
|
|
|
||||||
|
|
@ -18,23 +18,31 @@ The Hyperledger Fabric CA sample demonstrates the following:
|
||||||
|
|
||||||
## Running this sample
|
## Running this sample
|
||||||
|
|
||||||
1. The following images are required to run this sample:
|
1. To run this sample, simply run the *start.sh* script. You may do this
|
||||||
*hyperledger/fabric-ca-orderer*, *hyperledger/fabric-ca-peer*, and *hyperledger/fabric-ca-tools*
|
|
||||||
|
|
||||||
#### install the images
|
|
||||||
Run the *bootstrap.sh* script provided with this sample to download the
|
|
||||||
required images for fabric-ca sample. For the v1.2.0-rc1 release, you
|
|
||||||
will need to specify the version as follows:
|
|
||||||
|
|
||||||
```
|
|
||||||
bootstrap.sh 1.2.0-rc1
|
|
||||||
```
|
|
||||||
|
|
||||||
2. To run this sample, simply run the *start.sh* script. You may do this
|
|
||||||
multiple times in a row as needed since the *start.sh* script cleans up before
|
multiple times in a row as needed since the *start.sh* script cleans up before
|
||||||
starting each time.
|
starting each time. This sample can be run with the latest released version,
|
||||||
|
an older released version, or from locally built docker images as follows:
|
||||||
|
|
||||||
3. To stop the containers which are started by the *start.sh* script, you may run the *stop.sh* script.
|
a. By default, the sample is run with the latest released version of Fabric
|
||||||
|
and Fabric CA.
|
||||||
|
|
||||||
|
b. Older versions of Fabric and Fabric CA can be used by setting the
|
||||||
|
`FABRIC_TAG` environment variable. For example, `export FABRIC_TAG=1.2.0`
|
||||||
|
will run the sample with 1.2.0 version of Fabric and Fabric CA.
|
||||||
|
|
||||||
|
c. The sample can also be run with locally built Fabric and Fabric CA
|
||||||
|
docker images. Fabric and Fabric CA repositories must be cloned with following
|
||||||
|
commands:
|
||||||
|
|
||||||
|
`git clone https://github.com/hyperledger/fabric.git`
|
||||||
|
`git clone https://github.com/hyperledger/fabric-ca.git`
|
||||||
|
|
||||||
|
Then execute the `make docker-all` command from the fabric-ca repository. This will
|
||||||
|
build the necessary images based on the local source code. Before executing the
|
||||||
|
*start.sh* script, set the `FABRIC_TAG` environment variable to 'local' as follows:
|
||||||
|
`export FABRIC_TAG=local`.
|
||||||
|
|
||||||
|
2. To stop the containers which are started by the *start.sh* script, you may run the *stop.sh* script.
|
||||||
|
|
||||||
## Understanding this sample
|
## Understanding this sample
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright IBM Corp. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# current version of fabric-ca released
|
|
||||||
export CA_TAG=${1:-1.2.0}
|
|
||||||
|
|
||||||
dockerCaPull() {
|
|
||||||
echo "==> FABRIC CA IMAGE"
|
|
||||||
echo
|
|
||||||
for image in "" "-tools" "-orderer" "-peer"; do
|
|
||||||
docker pull hyperledger/fabric-ca${image}:$CA_TAG
|
|
||||||
docker tag hyperledger/fabric-ca${image}:$CA_TAG hyperledger/fabric-ca${image}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "===> Pulling fabric ca Image"
|
|
||||||
dockerCaPull ${CA_TAG}
|
|
||||||
|
|
||||||
echo "===> List out hyperledger docker images"
|
|
||||||
docker images | grep hyperledger/fabric-ca
|
|
||||||
|
|
@ -9,11 +9,24 @@
|
||||||
# This script builds the docker compose file needed to run this sample.
|
# This script builds the docker compose file needed to run this sample.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# IMPORTANT: The following default FABRIC_TAG value should be updated for each
|
||||||
|
# release after the fabric-orderer and fabric-peer images have been published
|
||||||
|
# for the release.
|
||||||
|
export FABRIC_TAG=${FABRIC_TAG:-1.2.0}
|
||||||
|
|
||||||
|
export FABRIC_CA_TAG=${FABRIC_CA_TAG:-${FABRIC_TAG}}
|
||||||
|
export NS=${NS:-hyperledger}
|
||||||
|
|
||||||
|
export ARCH="linux-amd64" # Docker images run on linux
|
||||||
|
CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${FABRIC_CA_TAG}.tar.gz
|
||||||
|
URL=https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${FABRIC_CA_TAG}/${CA_BINARY_FILE}
|
||||||
|
|
||||||
SDIR=$(dirname "$0")
|
SDIR=$(dirname "$0")
|
||||||
source $SDIR/scripts/env.sh
|
source $SDIR/scripts/env.sh
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
{
|
{
|
||||||
|
createDockerFiles
|
||||||
writeHeader
|
writeHeader
|
||||||
writeRootFabricCA
|
writeRootFabricCA
|
||||||
if $USE_INTERMEDIATE_CA; then
|
if $USE_INTERMEDIATE_CA; then
|
||||||
|
|
@ -26,6 +39,41 @@ function main {
|
||||||
log "Created docker-compose.yml"
|
log "Created docker-compose.yml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create various dockerfiles used by this sample
|
||||||
|
function createDockerFiles {
|
||||||
|
if [ "$FABRIC_TAG" = "local" ]; then
|
||||||
|
ORDERER_BUILD="image: hyperledger/fabric-ca-orderer"
|
||||||
|
PEER_BUILD="image: hyperledger/fabric-ca-peer"
|
||||||
|
TOOLS_BUILD="image: hyperledger/fabric-ca-tools"
|
||||||
|
else
|
||||||
|
createDockerFile orderer
|
||||||
|
ORDERER_BUILD="build:
|
||||||
|
context: .
|
||||||
|
dockerfile: fabric-ca-orderer.dockerfile"
|
||||||
|
createDockerFile peer
|
||||||
|
PEER_BUILD="build:
|
||||||
|
context: .
|
||||||
|
dockerfile: fabric-ca-peer.dockerfile"
|
||||||
|
createDockerFile tools
|
||||||
|
TOOLS_BUILD="build:
|
||||||
|
context: .
|
||||||
|
dockerfile: fabric-ca-tools.dockerfile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# createDockerFile
|
||||||
|
function createDockerFile {
|
||||||
|
{
|
||||||
|
echo "FROM ${NS}/fabric-${1}:${FABRIC_TAG}"
|
||||||
|
echo 'RUN apt-get update && apt-get install -y netcat jq && apt-get install -y curl && rm -rf /var/cache/apt'
|
||||||
|
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"
|
||||||
|
echo 'RUN chmod +x /usr/local/bin/fabric-ca-client'
|
||||||
|
echo 'ARG FABRIC_CA_DYNAMIC_LINK=false'
|
||||||
|
# libraries needed when image is built dynamically
|
||||||
|
echo 'RUN if [ "\$FABRIC_CA_DYNAMIC_LINK" = "true" ]; then apt-get install -y libltdl-dev; fi'
|
||||||
|
} > $SDIR/fabric-ca-${1}.dockerfile
|
||||||
|
}
|
||||||
|
|
||||||
# Write services for the root fabric CA servers
|
# Write services for the root fabric CA servers
|
||||||
function writeRootFabricCA {
|
function writeRootFabricCA {
|
||||||
for ORG in $ORGS; do
|
for ORG in $ORGS; do
|
||||||
|
|
@ -46,7 +94,7 @@ function writeIntermediateFabricCA {
|
||||||
function writeSetupFabric {
|
function writeSetupFabric {
|
||||||
echo " setup:
|
echo " setup:
|
||||||
container_name: setup
|
container_name: setup
|
||||||
image: hyperledger/fabric-ca-tools
|
$TOOLS_BUILD
|
||||||
command: /bin/bash -c '/scripts/setup-fabric.sh 2>&1 | tee /$SETUP_LOGFILE; sleep 99999'
|
command: /bin/bash -c '/scripts/setup-fabric.sh 2>&1 | tee /$SETUP_LOGFILE; sleep 99999'
|
||||||
volumes:
|
volumes:
|
||||||
- ./scripts:/scripts
|
- ./scripts:/scripts
|
||||||
|
|
@ -173,7 +221,7 @@ function writeOrderer {
|
||||||
MYHOME=/etc/hyperledger/orderer
|
MYHOME=/etc/hyperledger/orderer
|
||||||
echo " $ORDERER_NAME:
|
echo " $ORDERER_NAME:
|
||||||
container_name: $ORDERER_NAME
|
container_name: $ORDERER_NAME
|
||||||
image: hyperledger/fabric-ca-orderer
|
$ORDERER_BUILD
|
||||||
environment:
|
environment:
|
||||||
- FABRIC_CA_CLIENT_HOME=$MYHOME
|
- FABRIC_CA_CLIENT_HOME=$MYHOME
|
||||||
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
|
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
|
||||||
|
|
@ -210,7 +258,7 @@ function writePeer {
|
||||||
MYHOME=/opt/gopath/src/github.com/hyperledger/fabric/peer
|
MYHOME=/opt/gopath/src/github.com/hyperledger/fabric/peer
|
||||||
echo " $PEER_NAME:
|
echo " $PEER_NAME:
|
||||||
container_name: $PEER_NAME
|
container_name: $PEER_NAME
|
||||||
image: hyperledger/fabric-ca-peer
|
$PEER_BUILD
|
||||||
environment:
|
environment:
|
||||||
- FABRIC_CA_CLIENT_HOME=$MYHOME
|
- FABRIC_CA_CLIENT_HOME=$MYHOME
|
||||||
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
|
- FABRIC_CA_CLIENT_TLS_CERTFILES=$CA_CHAINFILE
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@
|
||||||
#
|
#
|
||||||
# This script does everything required to run the fabric CA sample.
|
# This script does everything required to run the fabric CA sample.
|
||||||
#
|
#
|
||||||
|
# By default, this test is run with the latest released docker images.
|
||||||
|
#
|
||||||
|
# To run against a specific fabric/fabric-ca version:
|
||||||
|
# export FABRIC_TAG=1.2.0
|
||||||
|
#
|
||||||
|
# To run with locally built images:
|
||||||
|
# export FABRIC_TAG=local
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue