A minimal Hyperledger Fabric external (chaincode-as-a-service, CCaaS) server, used as a test fixture for deploying a chaincode from a pre-built image.
main.go— a trivial chaincode server exposing three functions:ping(liveness),put(write a key) andget(read it back). It readsCHAINCODE_IDandCHAINCODE_SERVER_ADDRESSfrom the environment, as the CCaaS runtime sets them, and listens for a chaincode server connection on that address. TLS is disabled.Dockerfile— builds the server into a small image.build.sh— builds that image locally.
This is a standalone Go module: it is compiled inside a container image and is not intended to be linked into another Go build.
Requires docker with buildx.
./build.shOverride the image name or tag if needed:
IMAGE=goledger/gochain-test-chaincode TAG=1.0.0 ./build.shThe script builds into the local Docker image store and does not push. Tag and push the result yourself if you want it in a registry.
The CCaaS runtime starts the container with CHAINCODE_ID and
CHAINCODE_SERVER_ADDRESS set and expects a chaincode server listening on that
address:
docker run --rm \
-e CHAINCODE_ID=mycc:1.0 \
-e CHAINCODE_SERVER_ADDRESS=0.0.0.0:9999 \
-p 9999:9999 \
goledger/gochain-test-chaincode:1.0.0