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: docs/cli/build.md
+61-1
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,7 @@ ARG ADDITIONAL_PACKAGE
70
70
RUN apk --no-cache add curl ${ADDITIONAL_PACKAGE} \
71
71
72
72
```
73
+
<<<<<<< HEAD
73
74
## 2.0 Pass ADDITIONAL_PACKAGE through `--build-arg`
74
75
75
76
There may be scenarios where a single native module need to be added to a build. A single-package build option could be added as described above. Alternatively a package could be specified through a `--build-arg`.
@@ -101,4 +102,63 @@ Remeber to add any `ARG` values to the template's Dockerfile:
101
102
ARG ARGNAME2
102
103
```
103
104
104
-
For more information about passing build arguments to Docker, please visit the [Docker documentation](https://docs.docker.com/engine/reference/commandline/build/)
105
+
For more information about passing build arguments to Docker, please visit the [Docker documentation](https://docs.docker.com/engine/reference/commandline/build/)
106
+
=======
107
+
108
+
## 2.1 Build options examples
109
+
110
+
Let's see some practical examples with the `build-option` flag.
111
+
112
+
* Use [Pillow](https://pillow.readthedocs.io/en/5.2.x/) for image processing in your Python function
113
+
114
+
Create function with
115
+
116
+
```
117
+
$ faas-cli new faas_black_and_white --lang python3 --prefix <your-docker-namespace>
118
+
```
119
+
120
+
Add `pillow` to `requirements.txt` .
121
+
122
+
Copy some resource images to `faas_black_and_white/`.
123
+
124
+
Edit `handler.py`:
125
+
126
+
```python
127
+
import os
128
+
fromPILimport Image
129
+
130
+
defhandle(req):
131
+
img = Image.open("function/"+ req)
132
+
133
+
blackAndWhite = img.convert('1')
134
+
135
+
blackAndWhite.save("function/blackAndWhite.jpeg")
136
+
137
+
withopen("function/blackAndWhite.jpeg", 'rb') as pic:
138
+
res = pic.read()
139
+
140
+
os.write(1, res)
141
+
return res
142
+
```
143
+
144
+
What the code does is to open an image, available in resources and convert it to black and white.
145
+
146
+
Now build the function with build options:
147
+
```
148
+
faas build -f faas_black_and_white.yml --build-option dev --build-option pillow
0 commit comments