Documentation
¶
Overview ¶
Package zeaburpack is the library of zbpack.
Index ¶
- Variables
- func Build(opt *BuildOptions) error
- func GenerateDockerfile(opt *GenerateDockerfileOptions) (string, error)
- func InjectDockerfile(dockerfile string, registry *string, variables map[string]string) string
- func InjectLabels(dockerfile string, planType types.PlanType, planMeta types.PlanMeta) string
- func Plan(opt PlanOptions) (types.PlanType, types.PlanMeta)
- func PlanAndOutputDockerfile(opt PlanOptions) error
- func PrintPlanAndMeta(plan types.PlanType, meta types.PlanMeta, writer io.Writer)
- func SupportedIdentifiers(config plan.ImmutableProjectConfiguration) []plan.IdentifierV2
- func SupportedPackers() []packer.V2
- type BuildOptions
- type FromStatement
- type GenerateDockerfileOptions
- type PlanOptions
Constants ¶
This section is empty.
Variables ¶
var ServerlessTarPath = filepath.Join( lo.Must(os.MkdirTemp("", "zbpack-buildkit-artifact-*")), "serverless-output.tar", )
ServerlessTarPath is the path to the serverless output tar file
Functions ¶
func Build ¶
func Build(opt *BuildOptions) error
Build will analyze the project, determine the plan and build the image.
func GenerateDockerfile ¶
func GenerateDockerfile(opt *GenerateDockerfileOptions) (string, error)
GenerateDockerfile calls the packers to generate a Dockerfile based on the plan type and meta.
func InjectDockerfile ¶
InjectDockerfile injects the environment variables and the Docker.io registry into the Dockerfile.
func InjectLabels ¶
InjectLabels injects language and framework labels into the Dockerfile. It adds the labels after the first FROM statement in the Dockerfile.
func Plan ¶
func Plan(opt PlanOptions) (types.PlanType, types.PlanMeta)
Plan returns the build plan and metadata.
func PlanAndOutputDockerfile ¶
func PlanAndOutputDockerfile(opt PlanOptions) error
PlanAndOutputDockerfile output dockerfile.
func PrintPlanAndMeta ¶
PrintPlanAndMeta prints the build plan and meta in a table format.
func SupportedIdentifiers ¶
func SupportedIdentifiers(config plan.ImmutableProjectConfiguration) []plan.IdentifierV2
SupportedIdentifiers returns all supported identifiers note that they are in the order of priority
func SupportedPackers ¶
SupportedPackers returns all supported identifiers
Types ¶
type BuildOptions ¶
type BuildOptions struct {
// SubmoduleName is the of the submodule to build.
// For example, if directory is considered as a Go project,
// submoduleName would be used to try file in `cmd` directory.
// in Zeabur internal system, this is the name of the service.
SubmoduleName *string
// HandlePlanDetermined is a callback function that will be called when
// the build plan is determined.
HandlePlanDetermined *func(types.PlanType, types.PlanMeta)
// LogWriter is a [io.Writer] that will be written when a log is emitted.
// nil to use the default log writer.
LogWriter io.Writer
// Path is the path to the project directory.
Path *string
// ResultImage is the name of the image that will be built.
ResultImage *string
// UserVars is a map of user variables that will be used in the Dockerfile.
UserVars *map[string]string
// Interactive is a flag to indicate if the build should be interactive.
Interactive *bool
CacheFrom *string
CacheTo *string
// ProxyRegistry is the registry to be used for the image.
// See referenceConstructor for more details.
ProxyRegistry *string
// PushImage is a flag to indicate if the image should be pushed to the registry.
PushImage bool
}
BuildOptions is the options for the Build function.
func (*BuildOptions) Log ¶
func (opt *BuildOptions) Log(msg string, args ...any)
Log writes a log message to the log writer.
It passes the parameters to fmt.Fprintf internally.
type FromStatement ¶
FromStatement represents a FROM statement in a Dockerfile.
func ParseFrom ¶
func ParseFrom(line string) (FromStatement, bool)
ParseFrom parses a FROM statement from a Dockerfile line.
func (FromStatement) String ¶
func (fs FromStatement) String() string
type GenerateDockerfileOptions ¶
type GenerateDockerfileOptions struct {
// PlanType is the plan type generated by the planner.
PlanType types.PlanType
// PlanMeta is the plan meta generated by the planner.
PlanMeta types.PlanMeta
}
GenerateDockerfileOptions is the options for generating a Dockerfile.
type PlanOptions ¶
type PlanOptions struct {
// SubmoduleName is the of the submodule to build.
// For example, if a directory is considered as a Go project,
// submoduleName would be used to try file in `cmd` directory.
// in Zeabur internal system, this is the name of the service.
SubmoduleName *string
// Path is the path to the project directory.
Path *string
// Subpath specifies the root directory to plan in the project directory.
Subpath *string
// Access token for GitHub, only used when Path is a GitHub URL.
AccessToken *string
// AWSConfig is the AWS configuration to access S3, required if Path is an S3 URL.
AWSConfig *plan.AWSConfig
}
PlanOptions is the options for Plan function.