faas/watchdog/Dockerfile
Thomas Schmidt 67598e58c5 Update projects to use Go 1.13
Fixes #1442

Signed-off-by: Thomas Schmidt <thomaschmidt@gmail.com>
2020-02-22 19:01:49 +00:00

43 lines
1.4 KiB
Docker

FROM golang:1.13 as build
ENV GO111MODULE=off
ENV CGO_ENABLED=0
ARG VERSION
ARG GIT_COMMIT
RUN mkdir -p /go/src/github.com/openfaas/faas/watchdog
WORKDIR /go/src/github.com/openfaas/faas/watchdog
COPY vendor vendor
COPY metrics metrics
COPY types types
COPY main.go .
COPY handler.go .
COPY readconfig.go .
COPY readconfig_test.go .
COPY requesthandler_test.go .
COPY version.go .
# Run a gofmt and exclude all vendored code.
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN go test -v ./...
# Stripping via -ldflags "-s -w"
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w \
-X main.GitCommit=$GIT_COMMIT \
-X main.Version=$VERSION" \
-installsuffix cgo -o watchdog . \
&& GOARM=7 GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w \
-X main.GitCommit=$GIT_COMMIT \
-X main.Version=$VERSION" \
-installsuffix cgo -o watchdog-armhf . \
&& GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w \
-X main.GitCommit=$GIT_COMMIT \
-X main.Version=$VERSION" \
-installsuffix cgo -o watchdog-arm64 . \
&& GOOS=windows CGO_ENABLED=0 go build -a -ldflags "-s -w \
-X main.GitCommit=$GIT_COMMIT \
-X main.Version=$VERSION" \
-installsuffix cgo -o watchdog.exe .