Skip to content

Instantly share code, notes, and snippets.

@WoodProgrammer
Forked from alexellis/Dockerfile
Created October 14, 2018 12:18
Show Gist options
  • Save WoodProgrammer/cfe7af9542aaa2fcf35e7fb119e32029 to your computer and use it in GitHub Desktop.
Save WoodProgrammer/cfe7af9542aaa2fcf35e7fb119e32029 to your computer and use it in GitHub Desktop.
Go with of-watchdog
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