Skip to content

Commit

Permalink
Remove prefix from logs
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Feb 13, 2021
1 parent b2dfa2c commit 5aa914d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
13 changes: 8 additions & 5 deletions 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
Expand Down Expand Up @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion template/golang-http/function/handler.go
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion template/golang-http/go.mod
@@ -1,6 +1,6 @@
module handler

go 1.13
go 1.15

replace handler/function => ./function

Expand Down
13 changes: 8 additions & 5 deletions 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
Expand Down Expand Up @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion template/golang-middleware/function/handler.go
Expand Up @@ -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))))
}
2 changes: 1 addition & 1 deletion template/golang-middleware/go.mod
@@ -1,5 +1,5 @@
module handler

go 1.13
go 1.15

replace handler/function => ./function

0 comments on commit 5aa914d

Please sign in to comment.