How Builds Work
A build in OKD is the process of transforming input parameters into a resulting object. Most often, builds are used to transform source code into a runnable container image.
A build configuration, or
BuildConfig, is characterized by a build strategy and one or more sources. The strategy determines the aforementioned process, while the sources provide its input.
The build strategies are:
And there are six types of sources that can be given as build input:
It is up to each build strategy to consider or ignore a certain type of source, as well as to determine how it is to be used. Binary and Git are mutually exclusive source types. Dockerfile and Image can be used by themselves, with each other, or together with either Git or Binary. The Binary source type is unique from the other options in how it is specified to the system.
A build configuration describes a single build definition and a set of triggers for when a new build should be created. Build configurations are defined by a
BuildConfig, which is a REST object that can be used in a POST to the API server to create a new instance.
Depending on how you choose to create your application using OKD, a
BuildConfig is typically generated automatically for you if you use the web console or CLI, and it can be edited at any time. Understanding the parts that make up a
BuildConfig and their available options can help if you choose to manually tweak your configuration later.
The following example
BuildConfig results in a new build every time a container image tag or the source code changes:
kind: "BuildConfig" apiVersion: "v1" metadata: name: "ruby-sample-build" (1) spec: runPolicy: "Serial" (2) triggers: (3) - type: "GitHub" github: secret: "secret101" - type: "Generic" generic: secret: "secret101" - type: "ImageChange" source: (4) git: uri: "https://github.com/openshift/ruby-hello-world" strategy: (5) sourceStrategy: from: kind: "ImageStreamTag" name: "ruby-20-centos7:latest" output: (6) to: kind: "ImageStreamTag" name: "origin-ruby-sample:latest" postCommit: (7) script: "bundle exec rake test"
|1||This specification will create a new
|3||You can specify a list of triggers, which cause a new build to be created.|
|6||After the container image is successfully built, it will be pushed into the repository described in the