-
-
Save WoodProgrammer/cfe7af9542aaa2fcf35e7fb119e32029 to your computer and use it in GitHub Desktop.
Go with of-watchdog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.8.3-alpine3.6 | |
RUN apk --no-cache add curl \ | |
&& echo "Pulling watchdog binary from Github." \ | |
&& curl -sSL https://github.com/openfaas-incubator/of-watchdog/releases/download/0.2.2/of-watchdog > /usr/bin/fwatchdog \ | |
&& chmod +x /usr/bin/fwatchdog \ | |
&& apk del curl --no-cache | |
WORKDIR /go/src/handler | |
COPY . . | |
# Run a gofmt and exclude all vendored code. | |
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } | |
RUN CGO_ENABLED=0 GOOS=linux \ | |
go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \ | |
go test $(go list ./... | grep -v /vendor/) -cover | |
FROM alpine:3.6 | |
RUN apk --no-cache add ca-certificates | |
# Add non root user | |
RUN addgroup -S app && adduser -S -g app app | |
RUN mkdir -p /home/app | |
RUN chown app /home/app | |
WORKDIR /home/app | |
COPY --from=0 /go/src/handler/handler . | |
COPY --from=0 /usr/bin/fwatchdog . | |
USER app | |
ENV fprocess="./handler" | |
ENV mode="streaming" | |
CMD ["./fwatchdog"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment