Skip to content

Commit 709484b

Browse files
authored
Merge pull request #13000 from bmcelvee/osdocs-82-build-strategies
osdocs-82 Add build strategy modules
2 parents add5f31 + 314a019 commit 709484b

30 files changed

+802
-1
lines changed

_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Topics:
3737
File: understanding-builds
3838
- Name: Creating build inputs
3939
File: creating-build-inputs
40+
- Name: Build strategies
41+
File: build-strategies
4042
- Name: Performing basic builds
4143
File: basic-build-operations
4244
---

builds/build-strategies.adoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// This assembly is included in the following assemblies:
2+
// * assembly/builds
3+
4+
//ifdef::context[:parent-context: {context}]
5+
6+
[id='build-strategies']
7+
= Build strategies
8+
include::modules/common-attributes.adoc[]
9+
:context: build-strategies
10+
toc::[]
11+
12+
The following sections define the primary supported build strategies, and how to
13+
use them.
14+
15+
// The following include statements pull in the module files that comprise the assembly. Include any combination of concept, procedure, or reference modules required to cover the user story. You can also include other assemblies.
16+
17+
ifdef::openshift-origin,openshift-enterprise,openshift-dedicated[]
18+
include::modules/builds-strategy-docker-build.adoc[leveloffset=+1]
19+
include::modules/builds-strategy-docker-from-image.adoc[leveloffset=+2]
20+
include::modules/builds-strategy-dockerfile-path.adoc[leveloffset=+2]
21+
include::modules/builds-strategy-docker-no-cache.adoc[leveloffset=+2]
22+
include::modules/builds-strategy-docker-environment-variables.adoc[leveloffset=+2]
23+
include::modules/builds-strategy-docker-build-arguments.adoc[leveloffset=+2]
24+
endif::[]
25+
include::modules/builds-strategy-s2i-build.adoc[leveloffset=+1]
26+
include::modules/builds-strategy-s2i-incremental-builds.adoc[leveloffset=+2]
27+
include::modules/builds-strategy-s2i-override-builder-image-scripts.adoc[leveloffset=+2]
28+
include::modules/builds-strategy-s2i-environment-variables.adoc[leveloffset=+2]
29+
include::modules/builds-strategy-s2i-environment-files.adoc[leveloffset=+3]
30+
include::modules/builds-strategy-s2i-buildconfig-environment.adoc[leveloffset=+3]
31+
include::modules/builds-strategy-s2i-ignore-source-files.adoc[leveloffset=+2]
32+
include::modules/builds-strategy-custom-build.adoc[leveloffset=+1]
33+
include::modules/builds-strategy-custom-from-image.adoc[leveloffset=+2]
34+
include::modules/builds-strategy-custom-expose-docker-socket.adoc[leveloffset=+2]
35+
include::modules/builds-strategy-custom-secrets.adoc[leveloffset=+2]
36+
include::modules/builds-strategy-custom-environment-variables.adoc[leveloffset=+2]
37+
include::modules/builds-strategy-pipeline-build.adoc[leveloffset=+1]
38+
include::modules/builds-strategy-pipeline-providing-jenkinsfile.adoc[leveloffset=+2]
39+
include::modules/builds-strategy-pipeline-environment-variables.adoc[leveloffset=+2]
40+
include::modules/builds-strategy-pipeline-mapping-buildconfig-jenkins.adoc[leveloffset=+3]
41+
include::modules/builds-strategy-force-pull-procedure.adoc[leveloffset=+1]
42+
include::modules/builds-strategy-docker-force-pull-example.adoc[leveloffset=+2]
43+
include::modules/builds-strategy-s2i-force-pull-example.adoc[leveloffset=+2]
44+
include::modules/builds-strategy-secrets-web-console.adoc[leveloffset=+1]
45+
include::modules/builds-strategy-enable-pulling-pushing.adoc[leveloffset=+1]

modules/builds-custom-strategy.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defined as described in Custom Strategy Options.
2121
2222
//[NOTE]
2323
//====
24-
//Add module above?
24+
//Add module above?
2525
//====
2626
2727
There is no technical difference between existing strategy secrets and the input
@@ -31,3 +31,9 @@ differently, based on your build use case.
3131
The input secrets are always mounted into the
3232
*_/var/run/secrets/openshift.io/build_* directory or your builder can parse the
3333
`$BUILD` environment variable, which includes the full build object.
34+
35+
36+
//[NOTE]
37+
//====
38+
//{product-title} does not guarantee your node has a docker socket to mount.
39+
//====
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Module included in the following assemblies:
2+
//
3+
// <List assemblies here, each on a new line>
4+
5+
[id='build-strategy-custom-build-{context}']
6+
= Custom build
7+
8+
The Custom build strategy allows developers to define a specific builder image
9+
responsible for the entire build process. Using your own builder image allows
10+
you to customize your build process.
11+
12+
A Custom builder image is a plain Docker-formatted container image embedded with
13+
build process logic, for example for building RPMs or base images. The
14+
`openshift/origin-custom-docker-builder` image is available on the
15+
https://registry.hub.docker.com/u/openshift/origin-custom-docker-builder[Docker
16+
Hub] registry as an example implementation of a Custom builder image.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Module included in the following assemblies:
2+
//* assembly/builds
3+
4+
[id='builds-strategy-custom-environment-variables-{context}']
5+
= Using environment variables for custom builds
6+
7+
To make environment variables available to the Custom build
8+
process, you can add environment variables to the `customStrategy` definition
9+
of the `BuildConfig`.
10+
11+
The environment variables defined there are passed to the pod that runs the
12+
custom build.
13+
14+
.Procedure
15+
16+
To define a custom HTTP proxy to be used during build:
17+
18+
[source,yaml]
19+
----
20+
customStrategy:
21+
...
22+
env:
23+
- name: "HTTP_PROXY"
24+
value: "http://myproxy.net:5187/"
25+
26+
----
27+
28+
ifdef::openshift-enterprise,openshift-origin[]
29+
Cluster administrators can also configure global build settings using Ansible.
30+
endif::[]
31+
32+
You can also manage environment variables defined in the `BuildConfig` with the
33+
`oc set env` command.
34+
35+
36+
37+
//[NOTE]
38+
//====
39+
// This module needs specific instructions and examples.
40+
// This is similar between Docker, S2I, and Custom.
41+
//====
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Module included in the following assemblies:
2+
//* assembly/builds
3+
4+
[id='builds-strategy-custom-expose-docker-socket-{context}']
5+
= Exposing the Docker socket
6+
7+
To allow the running of Docker commands and the building of container
8+
images from inside the container, the build container must be bound to an
9+
accessible socket.
10+
11+
.Procedure
12+
13+
Set the `exposeDockerSocket` option to *true*:
14+
15+
[source,yaml]
16+
----
17+
strategy:
18+
customStrategy:
19+
exposeDockerSocket: true
20+
----
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Module included in the following assemblies:
2+
//* assembly/builds
3+
4+
[id='builds-strategy-custom-from-image-{context}']
5+
= Using FROM image for custom builds
6+
7+
You can use the `customStrategy.from` section to indicate the image to use for the
8+
custom build
9+
10+
.Procedure
11+
12+
To set the `customStrategy.from` section:
13+
14+
[source,yaml]
15+
----
16+
strategy:
17+
customStrategy:
18+
from:
19+
kind: "DockerImage"
20+
name: "openshift/sti-image-builder"
21+
----
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Module included in the following assemblies:
2+
//* assembly/builds
3+
4+
[id='builds-strategy-custom-secrets-{context}']
5+
= Using secrets in custom builds
6+
7+
In addition to secrets for source and images that can be added to all build
8+
types, custom strategies allow adding an arbitrary list of secrets to the
9+
builder pod.
10+
11+
.Procedure
12+
13+
To mount each secret at a specific location:
14+
15+
[source,yaml]
16+
----
17+
strategy:
18+
customStrategy:
19+
secrets:
20+
- secretSource: <1>
21+
name: "secret1"
22+
mountPath: "/tmp/secret1" <2>
23+
- secretSource:
24+
name: "secret2"
25+
mountPath: "/tmp/secret2"
26+
----
27+
<1> `secretSource` is a reference to a secret in the same namespace as the
28+
build.
29+
<2> `mountPath` is the path inside the custom builder where the secret should
30+
be mounted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Module included in the following assemblies:
2+
//* assembly/builds
3+
4+
[id='builds-strategy-docker-build-arguments-{context}']
5+
= Adding Docker build arguments
6+
7+
You can set link:http://docs.docker.com/v1.7/reference/api/hub_registry_spec/#docker-registry-1-0[Docker
8+
build arguments] using the `BuildArgs` array. The build
9+
arguments will be passed to Docker when a build is started.
10+
11+
.Procedure
12+
13+
To set Docker build arguments, add entries to the `BuildArgs` array, which is
14+
located in the `dockerStrategy` definition of the `BuildConfig`. For example:
15+
16+
====
17+
[source,yaml]
18+
----
19+
dockerStrategy:
20+
...
21+
buildArgs:
22+
- name: "foo"
23+
value: "bar"
24+
----
25+
====
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Module included in the following assemblies:
2+
//
3+
// <List assemblies here, each on a new line>
4+
5+
[id='builds-strategy-docker-build-{context}']
6+
= Docker build
7+
8+
The Docker build strategy invokes the
9+
link:https://docs.docker.com/engine/reference/commandline/build/[docker build]
10+
command, and it therefore expects a repository with a *_Dockerfile_* and all
11+
required artifacts in it to produce a runnable image.

0 commit comments

Comments
 (0)