Skip to content
Snippets Groups Projects
Commit 4073ac04 authored by Gregory Haskins's avatar Gregory Haskins
Browse files

Refactor Dockerfile generation on golang


We make the Dockerfile logic consistent across all of the platforms
in prep for further cleanup later in the series.  No logic changes
are introduced to the resulting outputs, only the manner in which
they are generated.

Change-Id: Iebda8b3bf5211fd829b2f5ea8fa3af15bedd6544
Signed-off-by: default avatarGreg Haskins <gregory.haskins@gmail.com>
parent fff6ed66
Branches
Tags
No related merge requests found
......@@ -60,18 +60,20 @@ func writeChaincodePackage(spec *pb.ChaincodeSpec, tw *tar.Writer) error {
return fmt.Errorf("could not get chaincode name from path %s", urlLocation)
}
//let the executable's name be chaincode ID's name
newRunLine := fmt.Sprintf("RUN go install %s && mv $GOPATH/bin/%s $GOPATH/bin/%s", urlLocation, chaincodeGoName, spec.ChaincodeID.Name)
var buf []string
buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.golang.Dockerfile"))
//let the executable's name be chaincode ID's name
buf = append(buf, fmt.Sprintf("RUN go install %s && mv $GOPATH/bin/%s $GOPATH/bin/%s", urlLocation, chaincodeGoName, spec.ChaincodeID.Name))
//NOTE-this could have been abstracted away so we could use it for all platforms in a common manner
//However, it would still be docker specific. Hence any such abstraction has to be done in a manner that
//is not just language dependent but also container depenedent. So lets make this change per platform for now
//in the interest of avoiding over-engineering without proper abstraction
if viper.GetBool("peer.tls.enabled") {
newRunLine = fmt.Sprintf("%s\nCOPY src/certs/cert.pem %s", newRunLine, viper.GetString("peer.tls.cert.file"))
buf = append(buf, fmt.Sprintf("COPY src/certs/cert.pem %s", viper.GetString("peer.tls.cert.file")))
}
dockerFileContents := fmt.Sprintf("%s\n%s", cutil.GetDockerfileFromConfig("chaincode.golang.Dockerfile"), newRunLine)
dockerFileContents := strings.Join(buf, "\n")
dockerFileSize := int64(len([]byte(dockerFileContents)))
//Make headers identical by using zero time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment