The DockerBuild native step performs a build to produce a Docker image from a Dockerfile in a GitRepo source repository resource.
In the step configuration, you must provide the name (dockerFileName
) and directory (dockerFileLocation
) of the Dockerfile that contains the command to be processed by a docker build
command, as well as the name (dockerImageName
) and tag (dockerImageTag
) of the resulting image. The image is built on the build node, and information about that image is stored in the run state.
To build a Docker image that relies on a private base image:
Define the base image as an Image resource, with
autoPull
set totrue
.Specify the Image resource as one of the
inputResources
of the DockerBuild step.
To include artifacts in the Docker image that are not part of the GitRepo source repository:
Define a FileSpec resource that specifies the files to include from Artifactory.
Specify the FileSpec resource as one of the
inputResources
of the DockerBuild step.
Proper usage of DockerBuild step
DockerBuild and DockerPush steps must be assigned to the same affinityGroup
to share state. If this is not done, the output of DockerBuild will not be available for DockerPush. For more information on using affinityGroup
, see Running multiple steps on the same build node.
Docker Build and Push Quickstart
This Docker Build and Push quickstart demonstrates the definition of a pipeline that uses the DockerBuild and DockerPush native steps to build a single Docker Image, push it to Artifactory, and then publish the BuildInfo.
The following topics provide more information on DockerBuild Pipeline steps: