Skip to content

Commit 5aa914d

Browse files
committed
Remove prefix from logs
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent b2dfa2c commit 5aa914d

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

template/golang-http/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.8.0 as watchdog
2-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.12 as build
1+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.8.3 as watchdog
2+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.13 as build
33

44
ARG TARGETPLATFORM
55
ARG BUILDPLATFORM
@@ -27,11 +27,13 @@ RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
2727
go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
2828
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test handler/function/... -cover
2929

30-
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12
30+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.13
3131
# Add non root user and certs
3232
RUN apk --no-cache add ca-certificates \
33-
&& addgroup -S app && adduser -S -g app app \
34-
&& mkdir -p /home/app \
33+
&& addgroup -S app && adduser -S -g app app
34+
# Split instructions so that buildkit can run & cache
35+
# the previous command ahead of time.
36+
RUN mkdir -p /home/app \
3537
&& chown app /home/app
3638

3739
WORKDIR /home/app
@@ -47,5 +49,6 @@ USER app
4749
ENV fprocess="./handler"
4850
ENV mode="http"
4951
ENV upstream_url="http://127.0.0.1:8082"
52+
ENV prefix_logs="false"
5053

5154
CMD ["./fwatchdog"]

template/golang-http/function/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func Handle(req handler.Request) (handler.Response, error) {
1212
var err error
1313

14-
message := fmt.Sprintf("Hello world, input was: %s", string(req.Body))
14+
message := fmt.Sprintf("Body: %s", string(req.Body))
1515

1616
return handler.Response{
1717
Body: []byte(message),

template/golang-http/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module handler
22

3-
go 1.13
3+
go 1.15
44

55
replace handler/function => ./function
66

template/golang-middleware/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.8.0 as watchdog
2-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.12 as build
1+
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.8.3 as watchdog
2+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.13 as build
33

44
ARG TARGETPLATFORM
55
ARG BUILDPLATFORM
@@ -35,11 +35,13 @@ WORKDIR /go/src/handler
3535
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
3636
go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
3737

38-
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12
38+
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.13
3939
# Add non root user and certs
4040
RUN apk --no-cache add ca-certificates \
41-
&& addgroup -S app && adduser -S -g app app \
42-
&& mkdir -p /home/app \
41+
&& addgroup -S app && adduser -S -g app app
42+
# Split instructions so that buildkit can run & cache
43+
# the previous command ahead of time.
44+
RUN mkdir -p /home/app \
4345
&& chown app /home/app
4446

4547
WORKDIR /home/app
@@ -53,5 +55,6 @@ USER app
5355
ENV fprocess="./handler"
5456
ENV mode="http"
5557
ENV upstream_url="http://127.0.0.1:8082"
58+
ENV prefix_logs="false"
5659

5760
CMD ["./fwatchdog"]

template/golang-middleware/function/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ func Handle(w http.ResponseWriter, r *http.Request) {
1818
}
1919

2020
w.WriteHeader(http.StatusOK)
21-
w.Write([]byte(fmt.Sprintf("Hello world, input was: %s", string(input))))
21+
w.Write([]byte(fmt.Sprintf("Body: %s", string(input))))
2222
}

template/golang-middleware/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module handler
22

3-
go 1.13
3+
go 1.15
44

55
replace handler/function => ./function

0 commit comments

Comments
 (0)