Skip to content

Commit e67b50b

Browse files
ivanayovalexellis
authored andcommitted
Add documentation for build-option build flag
This change adds a new page to the CLI section documenting how to make use of `faas-cli build` flags. It gives details about `build-arg` and `build-option`. Signed-off-by: Ivana Yovcheva (VMware) <[email protected]>
1 parent 2106923 commit e67b50b

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

docs/cli/build.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Build functions
2+
3+
The OpenFaaS CLI supports various options for building a function.
4+
5+
For details and examples run
6+
7+
```bash
8+
faas-cli build --help
9+
```
10+
11+
## 1.0 Pass custom build arguments
12+
13+
You can pass build-time arguments to Docker with
14+
15+
```bash
16+
faas-cli build --build-arg ARGNAME1=argvalue1 --build-arg ARGNAME2=argvalue2
17+
```
18+
and use them in the template's Dockerfile with
19+
20+
```dockerfile
21+
ARG ARGNAME1
22+
ARG ARGNAME2
23+
```
24+
25+
For more information about passing build arguments to Docker, please visit the [Docker documentation](https://docs.docker.com/engine/reference/commandline/build/)
26+
27+
## 2.0 Apply build options
28+
29+
The OpenFaaS CLI allows you to run a build with different options, f.e. `dev`, `debug`, etc.
30+
31+
By default all templates are restricted to a minor build, which doesn't allow you to use third-party dependencies that require native (f.e C/C++) modules,
32+
like `libssh` in Ruby, `numpy` or `pandas` in Python, etc.
33+
34+
* How to use
35+
36+
The OpenFaaS CLI provides a solution by running a build in a dev mode, adding all required native modules.
37+
38+
You can do this with
39+
40+
```bash
41+
faas-cli build --lang python3 --build-option dev [--build-option debug]
42+
```
43+
44+
or in YAML:
45+
46+
```yaml
47+
build_options:
48+
- debug
49+
- dev
50+
```
51+
52+
If you are building multiple functions, we recommend using YAML configuration instead of CLI flag, as the flag is going to be applied to all functions listed in the YAML file.
53+
54+
> Currently only python and ruby templates are edited to support the feature.
55+
56+
* Edit templates to support dev build
57+
58+
One may want to support dev build for a custom template or edit the list of additional packages.
59+
60+
In order to modify a template to support dev build option, you should edit the `template.yml` with the following:
61+
62+
```yaml
63+
build_options:
64+
- name: dev
65+
packages: # A list of required packages
66+
- make
67+
- automake
68+
- gcc
69+
#- etc.
70+
- name: debug
71+
packages:
72+
- mg
73+
- iw
74+
#- etc.
75+
```
76+
77+
and edit `Dockerfile` with
78+
79+
```dockerfile
80+
# Add the following line
81+
ARG ADDITIONAL_PACKAGE
82+
83+
# Edit `RUN apk --no-cache add curl \` to the following
84+
RUN apk --no-cache add curl ${ADDITIONAL_PACKAGE} \
85+
86+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pages:
115115
- CLI:
116116
- Installation: ./cli/install.md
117117
- Create functions: ./cli/templates.md
118+
- Build functions: ./cli/build.md
118119
- Tutorials:
119120
- CLI with Node.js: ./tutorials/CLI-with-node.md
120121
- First Python Function: ./tutorials/first-python-function.md

0 commit comments

Comments
 (0)