diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3841cc4..e53db26 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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": {}, diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100755 index 0000000..e20d813 --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -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 diff --git a/.gitignore b/.gitignore index d9592b4..54e1952 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ # Dependency directories (remove the comment below to include it) # vendor/ .idea/ + +.fabric