Skip to content

Commit 773813d

Browse files
authored
Merge pull request #320 from wanjunlei/main
update doc for local source code build
2 parents 7b20cb2 + 0c6852c commit 773813d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

content/en/docs/concepts/function_build.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,37 @@ spec:
4040
> To push the function image to a container registry, you have to create a secret containing the registry's credential and add the secret to `imageCredentials`.
4141
> You can refer to the [prerequisites](../../getting-started/Quickstarts/prerequisites) for more info.
4242

43+
### Build functions from local source code
44+
45+
To build functions from local source code, we need a bundle image which contains the source code.
46+
We can use the following `Dockerfile` to build a bundle image.
47+
48+
```shell
49+
FROM scratch
50+
51+
WORKDIR /
52+
COPY samples samples/
53+
```
54+
55+
> We suggest using a empty image such as `scratch` as the base image of the bundle image, a non-empty base image may cause the source code copy to fail.
56+
57+
The `srcRepo` of function should be changed like this.
58+
59+
```yaml
60+
apiVersion: core.openfunction.io/v1beta1
61+
kind: Function
62+
metadata:
63+
name: logs-async-handler
64+
spec:
65+
build:
66+
srcRepo:
67+
bundleContainer:
68+
image: openfunctiondev/local-source
69+
sourceSubPath: "/samples/functions/async/logs-handler-function/"
70+
```
71+
72+
> The `sourceSubPath` is the absolute path of the source code in the bundle image.
73+
4374
## Build functions with the pack CLI
4475

4576
Usually it's necessary to build function images directly from local source code especially for debug purpose or for offline environment. You can use the pack CLI for this.

0 commit comments

Comments
 (0)