Sample-functions: Get watchdog using curl instead of ADD - Docs

Convert all sample-functions to use curl to get the watchdog as
it can be cached by Docker. Issue #841

Signed-off-by: Radoslav Dimitrov <rdimitrow@gmail.com>
This commit is contained in:
Radoslav Dimitrov
2018-09-02 23:44:06 +03:00
committed by Alex Ellis
parent c062e4dbde
commit c821585b39
2 changed files with 29 additions and 4 deletions

View File

@ -36,7 +36,7 @@ Example Dockerfile for an `echo` function:
```
FROM alpine:3.7
ADD https://github.com/openfaas/faas/releases/download/0.8.0/fwatchdog /usr/bin
ADD https://github.com/openfaas/faas/releases/download/0.9.0/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
# Define your binary here
@ -45,6 +45,15 @@ ENV fprocess="/bin/cat"
CMD ["fwatchdog"]
```
**Tip:**
You can optimize Docker to cache getting the watchdog by using curl, instead of ADD.
To do so, replace the related lines with:
```
RUN apk --no-cache add curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.9.0/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog
```
**Implementing a health-check**
At any point in time, if you detect that your function has become unhealthy and needs to restart, then you can delete the `/tmp/.lock` file which invalidates the check and causes Swarm to re-schedule the function.