From 5aa914d4975e5456382d22a1ef9c6758bfea4ad5 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Sat, 13 Feb 2021 09:37:41 +0000 Subject: [PATCH] Remove prefix from logs Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- template/golang-http/Dockerfile | 13 ++++++++----- template/golang-http/function/handler.go | 2 +- template/golang-http/go.mod | 2 +- template/golang-middleware/Dockerfile | 13 ++++++++----- template/golang-middleware/function/handler.go | 2 +- template/golang-middleware/go.mod | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/template/golang-http/Dockerfile b/template/golang-http/Dockerfile index 5cd767b..7376316 100644 --- a/template/golang-http/Dockerfile +++ b/template/golang-http/Dockerfile @@ -1,5 +1,5 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.8.0 as watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.12 as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.8.3 as watchdog +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.13 as build ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -27,11 +27,13 @@ RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build --ldflags "-s -w" -a -installsuffix cgo -o handler . RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test handler/function/... -cover -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.13 # Add non root user and certs RUN apk --no-cache add ca-certificates \ - && addgroup -S app && adduser -S -g app app \ - && mkdir -p /home/app \ + && addgroup -S app && adduser -S -g app app +# Split instructions so that buildkit can run & cache +# the previous command ahead of time. +RUN mkdir -p /home/app \ && chown app /home/app WORKDIR /home/app @@ -47,5 +49,6 @@ USER app ENV fprocess="./handler" ENV mode="http" ENV upstream_url="http://127.0.0.1:8082" +ENV prefix_logs="false" CMD ["./fwatchdog"] diff --git a/template/golang-http/function/handler.go b/template/golang-http/function/handler.go index 877ef17..0629469 100644 --- a/template/golang-http/function/handler.go +++ b/template/golang-http/function/handler.go @@ -11,7 +11,7 @@ import ( func Handle(req handler.Request) (handler.Response, error) { var err error - message := fmt.Sprintf("Hello world, input was: %s", string(req.Body)) + message := fmt.Sprintf("Body: %s", string(req.Body)) return handler.Response{ Body: []byte(message), diff --git a/template/golang-http/go.mod b/template/golang-http/go.mod index 59f85d3..fc2b72e 100644 --- a/template/golang-http/go.mod +++ b/template/golang-http/go.mod @@ -1,6 +1,6 @@ module handler -go 1.13 +go 1.15 replace handler/function => ./function diff --git a/template/golang-middleware/Dockerfile b/template/golang-middleware/Dockerfile index 865b76c..851aa59 100644 --- a/template/golang-middleware/Dockerfile +++ b/template/golang-middleware/Dockerfile @@ -1,5 +1,5 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} openfaas/of-watchdog:0.8.0 as watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.12 as build +FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/of-watchdog:0.8.3 as watchdog +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-alpine3.13 as build ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -35,11 +35,13 @@ WORKDIR /go/src/handler RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ go build --ldflags "-s -w" -a -installsuffix cgo -o handler . -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.13 # Add non root user and certs RUN apk --no-cache add ca-certificates \ - && addgroup -S app && adduser -S -g app app \ - && mkdir -p /home/app \ + && addgroup -S app && adduser -S -g app app +# Split instructions so that buildkit can run & cache +# the previous command ahead of time. +RUN mkdir -p /home/app \ && chown app /home/app WORKDIR /home/app @@ -53,5 +55,6 @@ USER app ENV fprocess="./handler" ENV mode="http" ENV upstream_url="http://127.0.0.1:8082" +ENV prefix_logs="false" CMD ["./fwatchdog"] diff --git a/template/golang-middleware/function/handler.go b/template/golang-middleware/function/handler.go index 12802da..c52b947 100644 --- a/template/golang-middleware/function/handler.go +++ b/template/golang-middleware/function/handler.go @@ -18,5 +18,5 @@ func Handle(w http.ResponseWriter, r *http.Request) { } w.WriteHeader(http.StatusOK) - w.Write([]byte(fmt.Sprintf("Hello world, input was: %s", string(input)))) + w.Write([]byte(fmt.Sprintf("Body: %s", string(input)))) } diff --git a/template/golang-middleware/go.mod b/template/golang-middleware/go.mod index 5ef5804..f8c3c1c 100644 --- a/template/golang-middleware/go.mod +++ b/template/golang-middleware/go.mod @@ -1,5 +1,5 @@ module handler -go 1.13 +go 1.15 replace handler/function => ./function