Understanding build configurations

The following sections define the concept of a build, build configuration, and outline the primary build strategies available.

BuildConfigs

A build configuration describes a single build definition and a set of triggers for when a new build is 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.

A build configuration, or BuildConfig, is characterized by a build strategy and one or more sources. The strategy determines the process, while the sources provide its input.

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 change your configuration later.

The following example BuildConfig results in a new build every time a container image tag or the source code changes:

BuildConfig object definition

  1. kind: BuildConfig
  2. apiVersion: build.openshift.io/v1
  3. metadata:
  4. name: "ruby-sample-build" (1)
  5. spec:
  6. runPolicy: "Serial" (2)
  7. triggers: (3)
  8. -
  9. type: "GitHub"
  10. github:
  11. secret: "secret101"
  12. - type: "Generic"
  13. generic:
  14. secret: "secret101"
  15. -
  16. type: "ImageChange"
  17. source: (4)
  18. git:
  19. uri: "https://github.com/openshift/ruby-hello-world"
  20. strategy: (5)
  21. sourceStrategy:
  22. from:
  23. kind: "ImageStreamTag"
  24. name: "ruby-20-centos7:latest"
  25. output: (6)
  26. to:
  27. kind: "ImageStreamTag"
  28. name: "origin-ruby-sample:latest"
  29. postCommit: (7)
  30. script: "bundle exec rake test"
1This specification creates a new BuildConfig named ruby-sample-build.
2The runPolicy field controls whether builds created from this build configuration can be run simultaneously. The default value is Serial, which means new builds run sequentially, not simultaneously.
3You can specify a list of triggers, which cause a new build to be created.
4The source section defines the source of the build. The source type determines the primary source of input, and can be either Git, to point to a code repository location, Dockerfile, to build from an inline Dockerfile, or Binary, to accept binary payloads. It is possible to have multiple sources at once. For more information about each source type, see “Creating build inputs”.
5The strategy section describes the build strategy used to execute the build. You can specify a Source , Docker, or Custom strategy here. This example uses the ruby-20-centos7 container image that Source-to-image (S2I) uses for the application build.
6After the container image is successfully built, it is pushed into the repository described in the output section.
7The postCommit section defines an optional build hook.