Open jkneubuh opened 2 years ago
On the compose
file route; the mounts of directories make it un-practical to follow the same route. at least not with doing a lot work.
An alternative to this is something more like this script below. I'm trialling for use in the other repos, as way to just get the test-network ready for testing. In this context, the script is run before the tests, and it will setup the docker images, binaries, and the test-network from fabric-samples ONLY. All in a subdirectory (that either is empty or will be created)
#!/bin/bash
# fabric-quickly.sh
set -e -u -o pipefail
ROOTDIR=$(cd "$(dirname "$0")" && pwd)
prefix=fab-test-net
tempdir=$(mktemp -d -t "$prefix.XXXXX") || error_exit "Error creating temporary directory"
DIR=${ROOTDIR}/fabric-install
if [ -d "$DIR" ]
then
if [ "$(ls -A $DIR)" ]; then
echo "test-network $DIR is not Empty"
exit 1
fi
else
echo "Directory $DIR not found. Creating..."
mkdir -p ${DIR}
fi
pushd ${tempdir}
curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
&& chmod +x install-fabric.sh \
&& ./install-fabric.sh binary samples
popd
cp -r ${tempdir}/fabric-samples/bin ${DIR}
cp -r ${tempdir}/fabric-samples/config ${DIR}
cp -r ${tempdir}/fabric-samples/test-network ${DIR}
rm -Rf "$tempdir"
the network.sh
script would be amenable to use if it was able to be run from any directory, PR #634 has been pushed up for this.
Here's a target:
set a kube context. (new KIND cluster, or k3s local, or remote AKS, IKS, ...)
run a single kubectl apply
command, pointing at an aggregate yaml manifest via git URL. The test network + channel + chaincode + ingress emerges.
run a single kubectl
command to extract connection profiles, certificates, and MSP structures.
run fabric samples on the host OS, using the connection profiles and via passthrough gRPC ingress to the gateway service.
Effectively, you push a button and Voila! : the test network emerges and is ready for Gateway app development.
@mbwhite showed an amazing demonstration / prototype by embedding a "zero-to-blockchain-in-one-command" example with the hlfsupport-in-a-box project. HLF-in-a-box sets up all of the project dependencies, ansible playbooks, and scripting necessary to spin up a network on a remote OCP with a single command.
This Issue / Feature describes an analogous command, but targeting the core Fabric test-network and test-network-k8s projects.
To implement this feature, bundle all of the pre-requisites, scripts, manifests, etc. etc... necessary to spin up a test network, and package everything together in a runnable Docker image. In a kubernetes cluster, the image can just "run" with a kubectl run (or job) in the cluster, inheriting the default service account and kube context. It's not immediately clear how the mechanics will work for the compose-based network, but it certainly would be convenient to run the setup with a single
docker run
command.The expected usage is:
Some really convenient extension ideas:
After the user runs the "in-a-box" installer, leave the MSP residue and certificates in a convenient location for local dev.
Have the installer set up Nginx Ingress resources for the Fabric nodes. (We could use the .nip.io or .vcap.me DNS host aliases to set up stable host names binding to the Nginx ingress controller on the host NIC.)
???