faas/watchdog/Dockerfile
Sean Smith 2292aab829 Update to golang 1.9.7
Issue #660 has been open for a while to update to 1.9.6, this
performs the update to the latest in the 1.9 release (1.9.7)

Signed-off-by: Sean Smith <sean@wwsean08.com>
2018-06-16 08:37:11 -07:00

37 lines
1.3 KiB
Docker

FROM golang:1.9.7 as build
ARG VERSION
ARG GIT_COMMIT
RUN mkdir -p /go/src/github.com/openfaas/faas/watchdog
WORKDIR /go/src/github.com/openfaas/faas/watchdog
COPY main.go .
COPY handler.go .
COPY readconfig.go .
COPY readconfig_test.go .
COPY requesthandler_test.go .
COPY types types
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 .