get.porter.sh/porter@v1.3.0/pkg/build/build.go (about)

     1  package build
     2  
     3  import (
     4  	"context"
     5  	"path/filepath"
     6  
     7  	"get.porter.sh/porter/pkg/manifest"
     8  )
     9  
    10  var (
    11  	// DOCKER_FILE is the file generated before running a docker build.
    12  	DOCKER_FILE = filepath.Join(LOCAL_CNAB, "Dockerfile")
    13  
    14  	// LOCAL_CNAB is the generated directory where porter stages the /cnab directory.
    15  	LOCAL_CNAB = ".cnab"
    16  
    17  	// LOCAL_APP is the generated directory where porter stages the /cnab/app directory.
    18  	LOCAL_APP = filepath.Join(LOCAL_CNAB, "app")
    19  
    20  	// LOCAL_BUNDLE is the generated bundle.json file.
    21  	LOCAL_BUNDLE = filepath.Join(LOCAL_CNAB, "bundle.json")
    22  
    23  	// LOCAL_RUN is the path to the generated CNAB entrypoint script, located at /cnab/app/run.
    24  	LOCAL_RUN = filepath.Join(LOCAL_APP, "run")
    25  
    26  	// LOCAL_MANIFEST is the canonical Porter manifest generated from the
    27  	// user-provided manifest and any dynamic overrides
    28  	LOCAL_MANIFEST = filepath.Join(LOCAL_APP, "porter.yaml")
    29  
    30  	// LOCAL_MIXINS is the path where Porter stages the /cnab/app/mixins directory.
    31  	LOCAL_MIXINS = filepath.Join(LOCAL_APP, "mixins")
    32  
    33  	// BUNDLE_DIR is the directory where the bundle is located in the CNAB execution environment.
    34  	BUNDLE_DIR = "/cnab/app"
    35  
    36  	// PORTER_MIXINS_TOKEN can control where mixin instructions will be placed in
    37  	// Dockerfile.
    38  	PORTER_MIXINS_TOKEN = "# PORTER_MIXINS"
    39  
    40  	// PORTER_INIT_TOKEN controls where Porter's image initialization
    41  	// instructions are placed in the Dockerfile.
    42  	PORTER_INIT_TOKEN = "# PORTER_INIT"
    43  )
    44  
    45  type Builder interface {
    46  	// BuildBundleImage using the bundle in the build context directory
    47  	BuildBundleImage(ctx context.Context, manifest *manifest.Manifest, opts BuildImageOptions) error
    48  
    49  	// TagBundleImage using the origTag and newTag values supplied
    50  	TagBundleImage(ctx context.Context, origTag, newTag string) error
    51  }
    52  
    53  // BuildImageOptions represents some flags exposed by docker.
    54  type BuildImageOptions struct {
    55  	// SSH is the set of docker build --ssh flags specified.
    56  	SSH []string
    57  
    58  	// Secrets is the set of docker build --secret flags specified.
    59  	Secrets []string
    60  
    61  	// BuildArgs is the set of docker build --build-arg specified.
    62  	BuildArgs []string
    63  
    64  	// BuildContexts is the set of docker build --build-context specified.
    65  	BuildContexts []string
    66  
    67  	// NoCache is the docker build --no-cache flag specified.
    68  	NoCache bool
    69  }