You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/serverless-build-func-kn.adoc
+46-9Lines changed: 46 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,38 @@
6
6
[id="serverless-build-func-kn_{context}"]
7
7
= Building functions
8
8
9
-
Before you can run a function, you must build the function project by using the `kn func build` command. This command creates an OCI container image that can be run locally on your computer or on an {product-title} cluster. The build command uses the function project name and the image registry name to construct a fully qualified image name for your function.
9
+
Before you can run a function, you must build the function project. If you are using the `kn func run` command, the function is built automatically. However, you can use the `kn func build` command to build a function without running it, which can be useful for advanced users or debugging scenarios.
10
10
11
-
By default, `kn func build` creates a container image using the Red Hat Source-to-Image (S2I) technology. To use the link:https://buildpacks.io/[CNCF Cloud Native Buildpacks] technology instead, supply the `-b` flag:
11
+
The `kn func build`command creates an OCI container image that can be run locally on your computer or on an {product-title} cluster. This command uses the function project name and the image registry name to construct a fully qualified image name for your function.
By default, `kn func build` creates a container image by using Red Hat Source-to-Image (S2I) technology.
17
+
18
+
.Example build command using Red Hat Source-to-Image (S2I)
19
+
[source,terminal]
20
+
----
21
+
$ kn func build
22
+
----
23
+
24
+
You can use link:https://buildpacks.io/[CNCF Cloud Native Buildpacks] technology instead, by adding the `--builder` flag to the command and specifying the `pack` strategy:
25
+
26
+
.Example build command using CNCF Cloud Native Buildpacks
The OpenShift Container Registry is used by default as the image registry for storing function images.
36
+
37
+
.Example build command using OpenShift Container Registry
14
38
[source,terminal]
15
39
----
16
-
$ kn func build -b pack
40
+
$ kn func build
17
41
----
18
42
19
43
.Example output
@@ -23,14 +47,13 @@ Building function image
23
47
Function image has been built, image: registry.redhat.io/example/example-function:latest
24
48
----
25
49
26
-
The OpenShift Container Registry is used by default as the image registry for storing function images. You can override this by using the `-r` flag:
50
+
You can override using OpenShift Container Registry as the default image registry by using the `--registry` flag:
27
51
28
-
.Example build command
52
+
.Example build command overriding OpenShift Container Registry to use quay.io
29
53
[source,terminal]
30
54
----
31
-
$ kn func build -r quay.io/username
55
+
$ kn func build --registry quay.io/username
32
56
----
33
-
// removed mentioning the `FUNC_REGISTRY` environment variable because we didn't provide an example and it seems unnecessary - can add it in later if it's important
34
57
35
58
.Example output
36
59
[source,terminal]
@@ -39,7 +62,21 @@ Building function image
39
62
Function image has been built, image: quay.io/username/example-function:latest
40
63
----
41
64
42
-
To learn more about `kn func build` command options, you can use the help command:
65
+
[id="serverless-build-func-kn-push_{context}"]
66
+
== Push flag
67
+
68
+
You can add the `--push` flag to a `kn func build` command to automatically push the function image after it is successfully built:
69
+
70
+
.Example build command using OpenShift Container Registry
71
+
[source,terminal]
72
+
----
73
+
$ kn func build --push
74
+
----
75
+
76
+
[id="serverless-build-func-kn-help_{context}"]
77
+
== Help command
78
+
79
+
You can use the help command to learn more about `kn func build` command options:
0 commit comments