Build Configuration
View Build Configuration
You can see build configuration in the Configuration tab of the Build.
-
Build Strategy
: Source means Source-to-Image -
Builder Image
indicates the image stream that is used to build the image -
Output To
indicates the built image reference in the internal Docker registry - You can click
Actions
-->Edit YAML
to see and edit build configuration - We normally reuse the S2I build configuration YAML file and modify it to suit our needs.
Create Build Configuration
- We will create a new build configuration in a new name
simple-webapp-docker
to differentiate from the existing one. - We will modify the source to use a new repository with the Dockerfile in it
- We are planning to use the Docker Build strategy so the strategy type will be Docker instead of Source
- We will use Ubuntu 16.04 as the source image
- We will output to image stream tag
simple-webapp-docker
- To create a new Build configuration, click
Add to Project
-->Import YAML / JSON
and then paste the YAML file.
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
app: simple-webapp-docker
name: simple-webapp-docker
spec:
output:
to:
kind: ImageStreamTag
name: 'simple-webapp-docker:latest'
runPolicy: Serial
source:
git:
ref: master
uri: 'https://github.com/mmumshad/simple-webapp-docker.git'
type: Git
strategy:
dockerStrategy:
from:
kind: DockerImage
name: 'ubuntu:16.04'
type: Docker
- The new build is now using Docker Image strategy.
- Click Start Build to start building
- The build cannot start with status
Invalid output reference
- This is because of the image stream tag
simple-webapp-docker:latest
does not exists - Create a new image stream tag by copying YAML configuration from the existing image stream tag
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
labels:
app: simple-webapp-docker
name: simple-webapp-docker
The build should now start
Build Triggers
- We would like the Builds to trigger automatically when we make a change to our application code.
- The code repository needs to send a message to OpenShift notifying it of the new events.
- On receiving this notification, OpenShift will automatically trigger a new build.
- This is done using Web Hooks
- A Web Hook is an event notification technique that sends an HTTP Post request to a predefined URL when an event occurs.
- Most code repositories such as GitHub, GitLab, and Bitbucket comes with built-in support for Web Hooks.
- You can find the URL in the build configuration page on OpenShift, under the Configuration tab.
You need to make sure that Code repository is able to access OpenShift using the IP address in the URL.
Workshop
- In build configuration, click
Action
-->Edit
- Add a new GitHub webhook
- Go to your repository on GitHub and create a new web hook
- Try to make change to
app.py
and commit. The build should be triggered.
In your environment, you may need to Disable SSL verification.