Skip to content

Commit d439d72

Browse files
committed
Details on streaming mode
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent ce85065 commit d439d72

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/openfaas-pro/builder.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,58 @@ You may need to enable build arguments for the Dockerfile, these can be passed t
290290
}
291291
```
292292

293+
## How to stream the logs and status output from a build
294+
295+
> Note: this feature requires a version later than `0.4.3`.
296+
297+
By default, the builder will prepare all logs and statuses in memory, and to send them after the build is completed.
298+
299+
If you would like to display live feedback to your users, you can set a HTTP Accept header of `application/x-ndjson` and the builder will stream the logs and status output as they are generated.
300+
301+
```bash
302+
curl -H "Accept: application/x-ndjson" \
303+
-H "X-Build-Signature: sha256=$HMAC" \
304+
--silent \
305+
http://127.0.0.1:8081/build -X POST --data-binary @req.tar | jq
306+
```
307+
308+
The intermediate output is identified by the `status` field containing `in_progress`:
309+
310+
```json
311+
{
312+
"log": [
313+
"v: 2021-10-20T16:48:34Z [ship 1/16] WORKDIR /home/app/",
314+
"v: 2021-10-20T16:48:34Z exporting to image 8.01s"
315+
],
316+
"image": "ttl.sh/alexellis2/test-image-hello:0.1.0",
317+
"status": "in_progress",
318+
"duration": 0.201
319+
}
320+
```
321+
322+
Upon completion, the `status` field will contain `success` or `failure`.
323+
324+
```json
325+
{
326+
327+
"image": "ttl.sh/alexellis2/test-image-hello:0.1.0",
328+
"status": "success",
329+
"duration": 0.843
330+
}
331+
```
332+
333+
When the build fails, further details may be included in the `error` field.
334+
335+
```json
336+
{
337+
338+
"image": "ttl.sh/alexellis2/test-image-hello:0.1.0",
339+
"status": "failure",
340+
"error": "failed to solve: process \"/bin/sh -c npm i\" did not complete successfully: exit code: 1",
341+
"duration": 0.843
342+
}
343+
```
344+
293345
## How to perform multi-arch builds
294346

295347
You may wish to cross-compile a function to run on an arm64 host, if so, you can provide a `platform` key in the configuration file.

0 commit comments

Comments
 (0)