util

package
v0.0.0-...-98d3023 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerBuild

func DockerBuild(opts DockerBuildOptions, client *docker.Client) error

------------------------------------------------------------------------------------------- DockerBuild ------------------------------------------------------------------------------------------- This function allows a "pass-through" build of chaincode within a docker container as an alternative to using standard "docker build" + Dockerfile mechanisms. The plain docker build is somewhat limiting due to the resulting image that is a superset composition of the build-time and run-time environments. This superset can be problematic on several fronts, such as a bloated image size, and additional security exposure associated with applications that are not needed, etc.

Therefore, this mechanism creates a pipeline consisting of an ephemeral docker container that accepts source code as input, runs some function (e.g. "go build"), and outputs the result. The intention is that this output will be consumed as the basis of a streamlined container by installing the output into a downstream docker-build based on an appropriate minimal image.

The input parameters are fairly simple:

  • Image: (optional) The builder image to use or "chaincode.builder"
  • Cmd: The command to execute inside the container.
  • InputStream: A tarball of files that will be expanded into /chaincode/input.
  • OutputStream: A tarball of files that will be gathered from /chaincode/output after successful execution of Cmd.

-------------------------------------------------------------------------------------------

func GetDockerImageFromConfig

func GetDockerImageFromConfig(path string) string

GetDockerImageFromConfig replaces variables in the config

func WriteFileToPackage

func WriteFileToPackage(localpath string, packagepath string, tw *tar.Writer) error

WriteFileToPackage writes a file to a tar stream.

func WriteFolderToTarPackage

func WriteFolderToTarPackage(tw *tar.Writer, srcPath string, excludeDirs []string, includeFileTypeMap map[string]bool, excludeFileTypeMap map[string]bool) error

WriteFolderToTarPackage writes source files to a tarball. This utility is used for node js chaincode packaging, but not golang chaincode. Golang chaincode has more sophisticated file packaging, as implemented in golang/platform.go.

Types

type DockerBuildOptions

type DockerBuildOptions struct {
	Image        string
	Cmd          string
	Env          []string
	InputStream  io.Reader
	OutputStream io.Writer
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL