This topic tells you how to build a Kubernetes application from a Dockerfile on Tanzu Platform.
Before you begin
Before you can deploy an app in a Space, you must:
-
Install Tanzu CLI v1.5.3 or later. See Installing the Tanzu CLI.
-
Install the latest version of the Tanzu CLI
app-developer
plug-in group:- If the
app-developer
plug-in group is already installed, verify that you’re using the latest version of the build plug-in by running:
tanzu plugin upgrade build
- If the
app-developer
plug-in group is not present, install it by running:
tanzu plugin install --group vmware-tanzu/app-developer:v1.1
- If the
-
Log in to Tanzu Platform using the Tanzu CLI:
tanzu login
Initialize a ContainerApp
Before you build your application, your must initialize a ContainerApp for it. The ContainerApp defines the default build and runtime configuration for your application and is used as an input to tanzu build
. For more information about ContainerApps, see What is a ContainerApp.
To initialize a ContainerApp:
-
Go to the root of your source code:
cd YOUR-REPO-LOCATION
-
Initialize the ContainerApp by running:
tanzu app init APP-NAME --build-type dockerfile
Answer the prompts.
-
(Optional) If your Dockerfile has a name other than
Dockerfile
or is not in the root of the build workspace, you can provide its path relative to the build workspace root by running:tanzu app config build dockerfile set path=PATH-TO-DOCKERFILE
For example:
$ tanzu app config build dockerfile set path=sub-directory/Dockerfile.test Updated build type: dockerfile
The example searches for a Dockerfile named
Dockerfile.test
in a directory calledsub-directory
, which is at the root of the Project. -
(Optional) If you have a multi-stage Dockerfile where you only want a single stage to run, you can specify the name of the stage to build by running:
tanzu app config build dockerfile set stage=DOCKERFILE-STAGE
For example:
tanzu app config build dockerfile set stage=app-building-stage Updated build type: dockerfile
The example builds the stage
app-building-stage
in the Dockerfile you configured. The default Dockerfile isDockerfile
.You can configure the
stage
field in conjunction with thepath
field for your Dockerfile. For more information about multi-stage Dockerfiles, see the Docker documentation. -
To deploy your app, follow the procedure in Deploy your application.
Content feedback and comments