Skip to content

Commit

Permalink
Add nano test network to devcontainer
Browse files Browse the repository at this point in the history
Signed-off-by: James Taylor <[email protected]>
  • Loading branch information
jt-nti committed Apr 25, 2024
1 parent fdc5486 commit 60f50b5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"ghcr.io/devcontainers-contrib/features/mkdocs:2": {
"plugins": "mkdocs-material mike"
}
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
"postCreateCommand": ".devcontainer/postCreateCommand.sh"

// Configure tool-specific properties.
// "customizations": {},
Expand Down
40 changes: 40 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env sh
#
# SPDX-License-Identifier: Apache-2.0
#
set -eu

export GOOS=$(go env GOOS)
export GOARCH=$(go env GOARCH)

#
# Install yq
#
mkdir -p "${HOME}"/.local/bin
curl -sSLo "${HOME}"/.local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_${GOOS}_${GOARCH} && chmod +x "${HOME}"/.local/bin/yq

#
# Install fabric binaries and the nano test network
#
rm -r "${PWD}"/.fabric || true
mkdir "${PWD}"/.fabric
cd .fabric

curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh && chmod +x install-fabric.sh
./install-fabric.sh binary

export FABRIC_SAMPLES_COMMIT=20009ecd029fa887a8a98122fa5df0ec5181cdb1
curl -sSL "https://github.com/hyperledger/fabric-samples/archive/${FABRIC_SAMPLES_COMMIT}.tar.gz" | tar -xzf - --strip-components=1 fabric-samples-${FABRIC_SAMPLES_COMMIT}/test-network-nano-bash

cd ..

#
# Add k8s builder config to fabric core.yaml
#
# To install the k8s builder use the following command:
# GOBIN="${PWD}"/.fabric/builders/k8s_builder go install ./cmd/...
#
export FABRIC_K8S_BUILDER_PATH="${PWD}"/.fabric/builders/k8s_builder
mkdir -p "${FABRIC_K8S_BUILDER_PATH}"

yq -i '.chaincode.externalBuilders += { "name": "k8s_builder", "path": "${FABRIC_K8S_BUILDER_PATH}" | envsubst(ne), "propagateEnvironment": [ "CORE_PEER_ID", "KUBECONFIG_PATH" ] }' .fabric/config/core.yaml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
# Dependency directories (remove the comment below to include it)
# vendor/
.idea/

.fabric

0 comments on commit 60f50b5

Please sign in to comment.