By allowing you to define a specific builder image responsible for the entire build process, OpenShift Container Platform’s Custom build strategy was designed to fill a gap created with the increased popularity of creating container images. When there is a requirement for a build to still produce individual artifacts (packages, JARs, WARs, installable ZIPs, and base images, for example), a Custom builder image using the Custom build strategy is the perfect match to fill that gap.
A Custom builder image is a plain container image embedded with build process
logic, for example for building RPMs or base container images. The
openshift/origin-custom-docker-builder
image is available on the
Docker
Hub as an example implementation of a Custom builder image.
Additionally, the Custom builder allows implementing any extended build process, for example a CI/CD flow that runs unit or integration tests.
To fully leverage the benefits of the Custom build strategy, you must understand how to create a Custom builder image that will be capable of building desired objects.
Upon invocation, a custom builder image will receive the following environment variables with the information needed to proceed with the build:
Variable Name | Description |
---|---|
|
The entire serialized JSON of the |
|
The URL of a Git repository with source to be built. |
|
Uses the same value as |
|
Specifies the subdirectory of the Git repository to be used when building. Only present if defined. |
|
The Git reference to be built. |
|
The version of the OpenShift Container Platform master that created this build object. |
|
The Docker registry to push the image to. |
|
The Docker tag name for the image being built. |
|
The path to the Docker credentials for running a |
|
Specifies the path to the Docker socket, if exposing the Docker socket was
enabled in the build configuration (if |
It is recommended that you write your Custom builder image to only read the
information provided by the BUILD
environment variable, which conforms to an
OpenShift Container Platform API version. You can then parse the required information from the
build definition JSON instead of relying on the other individual environment
variables provided to the builder image. However, the individual environment
variables are provided for convenience if you do not want to parse the build
definition.
Although Custom builder image authors have great flexibility in defining the build process, your builder image must still adhere to the following required steps necessary for seamlessly running a build inside of OpenShift Container Platform:
Read the Build
object
definition, which contains all the necessary information about input parameters
for the build.
Run the build process.
If your build produces an image, push it to the build’s output location if it is defined. Other output locations can be passed with environment variables.