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

22
DEV.md
View File

@ -35,7 +35,7 @@ RUN go get github.com/microcosm-cc/bluemonday && \
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
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
ENV fprocess="/go/src/app/app"
@ -61,7 +61,7 @@ Update the Docker stack with this:
```
FROM alpine:latest
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
ENV fprocess="wc"
@ -78,7 +78,23 @@ Update your Docker stack with this definition:
networks:
- functions
environment:
fprocess: "wc"
fprocess: "wc"
```
**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 apt-get update && apt-get install -y curl \
&& curl -sL https://github.com/openfaas/faas/releases/download/0.9.0/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
```
or with the following for Alpine based images:
```
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
```
### Testing your function