tanzu build

Create runnable app images from source code, using Cloud Native Buildpacks or Dockerfiles.

Usage

CLI Plugin: build | Target: global | Primarily used for: Platform Operations | Release Notes

Syntax:

  tanzu build [flags]
  tanzu build [flags] APP-NAME
  tanzu build [command]

If no app name is provided, build configuration is taken from all yaml files in the current (or sub) directories with “kind: ContainerApp”, potentially producing multiple images.

If the app name is provided, build configuration is taken from any file that has “kind: ContainerApp” and “metadata.name: APP-NAME” in the current (or sub) directory.

The output directory will be populated with a directory corresponding to each APP-NAME built.

Flags

  -r, --app-runtime string       Runtime to use, defaults to first in build plan
      --buildpacks-clear-cache   Clear buildpack build cache
  -o, --output-dir string        Path to output directory (will be created if it doesn't exist)

Commands

  config        Set build cli config

Global Flags

  -h, --help   help for build

Examples

  tanzu build where-for-dinner
  tanzu build ContainerApp/where-for-dinner
  tanzu build --output-dir /tmp/build

Building with Dockerfiles

By default, applications are built using Cloud Native Buildpacks. To build with a Dockerfile, ensure that spec.build.dockerfile is present in containerapp.yml:

spec:
  build:
    dockerfile:
      path: "Dockerfile" # (optional) the path to the Dockerfile relative to spec.build.path
      multiStageTarget: # (optional) the stage to target if there is more than one referenced in the Dockerfile

Note that --build-engine=platform is required to perform Dockerfile builds. Dockerfiles are applied using kaniko.

To provide build arguments to the Dockerfile, set spec.build.nonSecretEnv:

spec:
  build:
    nonSecretEnv:
      - name: "some-build-arg-name"
        value: "some-build-arg-value"

tanzu build config

Set the configuration for the Tanzu Build CLI.

Usage

  tanzu build config --build-plan-source-type <ucp|file|git> --<build-plan-source> <path|repo> --containerapp-registry <my-registry.io/some-project/{name}> [flags]
  tanzu build config [command]

Default location for configuration file is $HOME/.config/tanzu/build/config.yaml, but can be configured by setting $TANZU_BUILD_CONFIG to the desired path.

Flags

      --build-engine string             environment for running builds. Valid values: 'platform', 'daemon'.
      --build-plan-source string        URL, path or name of ContainerAppBuildPlan
      --build-plan-source-type string   method to fetch ContainerAppBuildPlan
      --containerapp-registry string    registry to push images to (overrides platform configuration). See above for templating instructions.
      --enable-experimental-features    enable experimental features

The build-engine is the containerized environment where builds happen.

  • The default is daemon, meaning that tanzu build will use the locally available Docker-compatible daemon to create build containers.
  • To run builds on Tanzu Platform, use platform. Note that the project must be configured for on-platform builds - speak to your platform operator to confirm.

The build-plan-source-type is the type of location where Tanzu Build will look for a ContainerAppBuildPlan.

  • The default value is ucp which will utilize the current Tanzu context to find the ContainerAppBuildPlan in UCP.
  • Other supported values are git and file.

The build-plan-source is the location where Tanzu Build will look for a ContainerAppBuildPlan using the “build-plan-source-type”.

  • For ucp type this can be empty. (passing a value here will result in Tanzu Build looking for a ContainerAppBuildPlan in UCP with that name"
  • For file type this value expects a relative or absolute path to the ContainerAppBuildPlan file. It will be resolved to an absolute path automatically.
  • For git type this value expects a git remote url that will be cloned by Tanzu Build. Tanzu build only support one ContainerAppBuildPlan in the repository at this time.

The containerapp-registry value is used to override the registry set in the ContainerAppBuildPlan. It supports the following templating to prevent image collisions:

  • {name} -> Will substitute the name of the ContainerApp
  • {contact. } -> Will substitute value of ContainerApp spec.contact. . An error will occur if the ContainerApp does not have this set.

NOTE Only spec.contact fields and name are valid templates.

Commands

  view        See build config

Examples

tanzu build config --build-plan-source-type=ucp --containerapp-registry some-registry.io/apps/{name}
tanzu build config --build-plan-source-type=file --build-plan-source=/workspace/path --containerapp-registry some-registry.io/{contact.team}/name
tanzu build config --build-plan-source-type=git --build-plan-source=https://github.com/myuser/my-config-repo --containerapp-registry some-registry.io/{contact.businessunit}/app-{name}

tanzu build config view

See the build config for the tanzu build command.

Usage

  tanzu build config view [flags]

Examples

tanzu build config view
check-circle-line exclamation-circle-line close-line
Scroll to top icon