Create runnable app images from source code, using Cloud Native Buildpacks or Dockerfiles.
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.
-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)
config Set build cli config
-h, --help help for build
tanzu build where-for-dinner
tanzu build ContainerApp/where-for-dinner
tanzu build --output-dir /tmp/build
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"
Set the configuration for the Tanzu Build CLI.
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.
--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.
daemon
, meaning that tanzu build
will use the locally available Docker-compatible daemon to create build containers.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.
ucp
which will utilize the current Tanzu context to find the ContainerAppBuildPlan in UCP.git
and file
.The build-plan-source
is the location where Tanzu Build will look for a ContainerAppBuildPlan using the “build-plan-source-type”.
ucp
type this can be empty. (passing a value here will result in Tanzu Build looking for a ContainerAppBuildPlan in UCP with that name"file
type this value expects a relative or absolute path to the ContainerAppBuildPlan file. It will be resolved to an absolute path automatically.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:
NOTE Only spec.contact
fields and name
are valid templates.
view See build config
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}
See the build config for the tanzu build
command.
tanzu build config view [flags]
tanzu build config view