区块链专列之三:External Chaincode Builder

举报
malajisi 发表于 2021/09/21 14:43:31 2021/09/21
【摘要】 Each type of chaincode (Go, Java, Node) has it's own Dockerfile but the contents of each Dockerfile are actually embedded within the peer binary itself. So unless you want to modify the peer itself...

Each type of chaincode (Go, Java, Node) has it's own Dockerfile but the contents of each Dockerfile are actually embedded within the peer binary itself. So unless you want to modify the peer itself, you cannot currently modify the contents of the Dockerfile(s). In the upcoming 2.0 release, you will have the ability to build your own chaincode launcher and then you can build/deploy chaincode in any manner you desire.

In the meantime, you can actually modify the contents of both the image used to build chaincode and the image used to run chaincode.

Building:
In Hyperledger Fabric version 1.x, building and launching chaincode was part of the peer implementation and therefore could not be customized without changing the source code. Prior to Hyplerdeger Fabric 2.0, the peer node used a hardcoded language specific logic (e.g. Golang), which generated an executable Docker container image from the chaincode source.
In v1.4.x, Go and Node chaincode are built using the fabric-ccenv image (you can find the Dockerfile under images/ccenv in the Fabric source tree). If you need any extra libraries for building, you can build your own image based on fabric-ccenv. Note that for Go we only take the binary chaincode which is built and use it in the actual chaincode container. For Node it's similar ... we take the contents of the installed Node app (including node_modules). You can specify your own chaincode builder by setting the "chaincode.builder" property in your peer's config file to the name of your custom image. Note that Java actually uses the "chaincode.java.runtime" image for building (fabric-javaenv found in the fabric-chaincode-java repository).

In 2.0, Node uses the fabric-nodeenv (found in the fabric-chaincode-node repository) image rather than fabric-ccenv.
Beginning with Hyperledger Fabric 2.0, operators are enabled to extend the peer with scripts (buildpacks) that can discover, build and launch chaincode.

Running:

In 1.4.x, the fabric-ccenv image will build the chaincode binary / Node app which will then be used to build the actual chaincode image. It basically just copies the contents into the runtime images which are specified by the "chaincode.golang.runtime", "chaincode.java.runtime", "chaincode.node.runtime" properties in the config file. So if for example your Go chaincode uses external shared libraries, you could add them to the appropriate base runtime image. For Go, this is the fabric-baseos image. For Node it is fabric-baseimage.

In 2.0, Node uses fabric-nodeenv for runtime as well.


-----------------------------------------
Gari Singh

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。