|
1 | | -FROM golang:1.11 |
| 1 | +FROM teamserverless/license-check:0.3.9 as license-check |
2 | 2 |
|
3 | | -RUN mkdir -p /go/src/github.com/openfaas-incubator/cron-connector/ |
| 3 | +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13 as build |
4 | 4 |
|
5 | | -WORKDIR /go/src/github.com/openfaas-incubator/cron-connector |
| 5 | +ARG TARGETPLATFORM |
| 6 | +ARG BUILDPLATFORM |
| 7 | +ARG TARGETOS |
| 8 | +ARG TARGETARCH |
6 | 9 |
|
| 10 | +ENV CGO_ENABLED=0 |
| 11 | +ENV GO111MODULE=on |
| 12 | +ENV GOFLAGS=-mod=vendor |
| 13 | + |
| 14 | +COPY --from=license-check /license-check /usr/bin/ |
| 15 | + |
| 16 | +WORKDIR /go/src/github.com/openfaas/cron-connector |
7 | 17 | COPY . . |
8 | 18 |
|
9 | | -ARG OPTS |
| 19 | +RUN license-check -path /go/src/github.com/openfaas/cron-connector/ --verbose=false "Alex Ellis" "OpenFaaS Author(s)" |
| 20 | +RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") |
| 21 | +RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test -v ./... |
| 22 | + |
| 23 | +RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \ |
| 24 | + && GIT_COMMIT=$(git rev-list -1 HEAD) \ |
| 25 | + && GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go build \ |
| 26 | + --ldflags "-s -w \ |
| 27 | + -X github.com/openfaas/cron-connector/version.GitCommit=${GIT_COMMIT}\ |
| 28 | + -X github.com/openfaas/cron-connector/version.Version=${VERSION}" \ |
| 29 | + -a -installsuffix cgo -o cron-connector . |
| 30 | + |
| 31 | +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship |
| 32 | +LABEL org.label-schema.license="MIT" \ |
| 33 | + org.label-schema.vcs-url="https://github.com/openfaas/cron-connector" \ |
| 34 | + org.label-schema.vcs-type="Git" \ |
| 35 | + org.label-schema.name="openfaas/cron-connector" \ |
| 36 | + org.label-schema.vendor="openfaas" \ |
| 37 | + org.label-schema.docker.schema-version="1.0" |
| 38 | + |
| 39 | +RUN apk --no-cache add \ |
| 40 | + ca-certificates |
10 | 41 |
|
11 | | -RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") && \ |
12 | | - go test -v ./ && \ |
13 | | - VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') && \ |
14 | | - GIT_COMMIT=$(git rev-list -1 HEAD) && \ |
15 | | - env ${OPTS} CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \ |
16 | | - -X github.com/openfaas-incubator/cron-connector/pkg/version.Release=${VERSION} \ |
17 | | - -X github.com/openfaas-incubator/cron-connector/pkg/version.SHA=${GIT_COMMIT}" \ |
18 | | - -a -installsuffix cgo -o cron-connector . && \ |
19 | | - addgroup --system app && \ |
20 | | - adduser --system --ingroup app app && \ |
21 | | - mkdir /scratch-tmp |
| 42 | +RUN addgroup -S app \ |
| 43 | + && adduser -S -g app app |
22 | 44 |
|
23 | | -# we can't add user in next stage because it's from scratch |
24 | | -# ca-certificates and tmp folder are also missing in scratch |
25 | | -# so we add all of it here and copy files in next stage |
| 45 | +WORKDIR /home/app |
26 | 46 |
|
27 | | -FROM scratch |
| 47 | +ENV http_proxy "" |
| 48 | +ENV https_proxy "" |
28 | 49 |
|
29 | | -COPY --from=0 /etc/passwd /etc/group /etc/ |
30 | | -COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ |
31 | | -COPY --from=0 --chown=app:app /scratch-tmp /tmp/ |
32 | | -COPY --from=0 /go/src/github.com/openfaas-incubator/cron-connector/cron-connector . |
| 50 | +COPY --from=build /go/src/github.com/openfaas/cron-connector/cron-connector . |
| 51 | +RUN chown -R app:app ./ |
33 | 52 |
|
34 | 53 | USER app |
35 | 54 |
|
36 | | -ENTRYPOINT ["./cron-connector"] |
| 55 | +CMD ["./cron-connector"] |
0 commit comments