Re: Customize chaincode docker image

Kimheng SOK


Thank for your detail explanation, I will discover it more.


On Wed, Sep 18, 2019 at 3:48 PM Gari Singh <garis@...> wrote:
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.


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 "" 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.


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.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

Gari Singh
Distinguished Engineer, CTO - IBM Blockchain
IBM Middleware
550 King St
Littleton, MA 01460
Cell: 978-846-7499

-----fabric@... wrote: -----
To: fabric@...
From: "Kimheng SOK"
Sent by: fabric@...
Date: 09/18/2019 03:28AM
Subject: [EXTERNAL] [Hyperledger Fabric] Customize chaincode docker image

Dear all,

Each time we instantiate or upgrade the chaincode, there is a new chaincode docker image and container exist.

If we want to customize the default chaincode image to install some other applications, so that when we instantiate the chaincode we have all the environment we want, how can we do it? Where does the chaincode dockerfile located?


Join to automatically receive all group messages.