mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 10:26:32 +00:00
Convert Gateway to Github Actions
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
@ -1,11 +1,15 @@
|
||||
FROM teamserverless/license-check:0.3.6 as license-check
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} teamserverless/license-check:0.3.6 as license-check
|
||||
|
||||
FROM golang:1.13-alpine3.11 as build
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build
|
||||
|
||||
ENV GO111MODULE=off
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
RUN apk add --no-cache curl ca-certificates
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY --from=license-check /license-check /usr/bin/
|
||||
|
||||
WORKDIR /go/src/handler
|
||||
@ -13,13 +17,13 @@ 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 \
|
||||
RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)"
|
||||
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
||||
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } \
|
||||
go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \
|
||||
go test $(go list ./... | grep -v /vendor/) -cover
|
||||
|
||||
FROM alpine:3.11 as ship
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
|
||||
# Add non-root user
|
||||
RUN addgroup -S app && adduser -S -g app app \
|
||||
&& mkdir -p /home/app \
|
||||
|
@ -1,38 +0,0 @@
|
||||
FROM teamserverless/license-check:0.3.6 as license-check
|
||||
|
||||
FROM golang:1.13-alpine3.11 as build
|
||||
|
||||
ENV GO111MODULE=off
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
RUN apk add --no-cache curl ca-certificates gcc musl-dev
|
||||
COPY --from=license-check /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/*"))" \
|
||||
&& go test $(go list ./... | grep -v /vendor/) -cover && \
|
||||
CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
|
||||
|
||||
FROM alpine:3.11
|
||||
# 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"]
|
||||
|
Reference in New Issue
Block a user