mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
Tested with local Docker build for each component. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
38 lines
951 B
Docker
38 lines
951 B
Docker
FROM golang:1.12-alpine3.11 as build
|
|
|
|
ENV GO111MODULE=off
|
|
ENV CGO_ENABLED=0
|
|
|
|
RUN apk add --no-cache curl ca-certificates
|
|
RUN curl -sLSf https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh \
|
|
&& mv ./license-check /usr/bin/
|
|
|
|
WORKDIR /go/src/handler
|
|
COPY . .
|
|
|
|
# Run a gofmt and exclude all vendored code.
|
|
|
|
RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)" \
|
|
&& test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \
|
|
&& 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.11 as ship
|
|
# Add non-root user
|
|
RUN addgroup -S app && adduser -S -g app app \
|
|
&& mkdir -p /home/app \
|
|
&& chown app /home/app
|
|
|
|
WORKDIR /home/app
|
|
|
|
COPY --from=build /go/src/handler/handler .
|
|
|
|
RUN chown -R app /home/app
|
|
|
|
USER app
|
|
|
|
WORKDIR /home/app
|
|
|
|
CMD ["./handler"]
|