The YAML schema for DockerBuild native step is as follows:
An alphanumeric string (underscores are permitted) that identifies the step.
DockerBuild for this step type.
Description of usage
|Must specify an affinity group string that is the same as specified in a subsequent DockerPush step.||Optional|
Optionally, you may also specify:
In addition, these tags can be defined to support the step's native operation:
Tags derived from Bash
All native steps derive from the Bash step. This means that all steps share the same base set of tags from Bash, while native steps have their own additional tags as well that support the step's particular function. So it's important to be familiar with the Bash step definition, since it's the core of the definition of all other steps.
Description of usage
|Directory containing the Dockerfile, which is the file that has Docker build configuration. This file is also used as the context for the Docker build. The path provided should be relative to the root of the input GitRepo repository. If no location is provided, the default is the root of the GitRepo repository.||Required|
|Name of the Dockerfile.||Required|
|The name of the Docker image to create. This can be set using environment variables or triggering a run using parameters.||Required|
|The tag for the Docker image to create. This can be set using environment variables or triggering a run using parameters.||Required|
Additional options for the docker build command.
The following examples use a GoLang Git repository represented by a GitRepo resource named
gosvc_app to create a Docker image that is published to Artifactory. They assume that an Artifactory integration named
MyArtifactory has been created, and that the Artifactory instance has a Docker repository mapped to
- These examples require an Artifactory Integration and a GitHub Integration.
- The Pipelines DSL for a similar example is available in this repository in the JFrog GitHub account.
- For a full tutorial, see Pipeline Example: Docker Build.
The following resources declarations support these examples. Not all of these resources are used in all examples.
Build a Docker image from a source repository
This example builds a Docker image to a Docker registry in Artifactory. The tag for the image is set to the pipeline's run number.
Build a Docker image with dockerOptions
This example demonstrates use of the
dockerOptions tag to set the
build-arg option for the Docker command. An environment variable named
build_number_env_variable is dynamically set to the pipeline's run number. The example assumes the environment variable is used in the Dockerfile commands.
Build a Docker image with a private base image
This example builds a Docker image that relies on a private base image stored in an Artifactory Docker repository.
Build a Docker image with files outside the current path
This example demonstrates building a Docker image that includes files outside of the current path. It pulls icon files stored in an Artifactory repository for integration art named
my-local-repo. It is assumed that the Dockerfile has a command that will include the files in
/icons into the image.
How it Works
When you use the DockerBuild native step in a pipeline, it performs the following functions in the background:
- cp (if there is a FileSpec input, copy those files to the root of the cloned GitRepo input)
- docker build
- add_run_variables (add several variables that are later used when pushing the Docker image or publishing build info)
- jfrog rt build-collect-env (collect environment information to be later published as part of build info)
- add_run_files (save information collected for build info)