forked from openfaas/faas-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.redist
62 lines (50 loc) · 2.92 KB
/
Dockerfile.redist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Build stage
FROM golang:1.11 as builder
WORKDIR /usr/bin/
RUN curl -sLSf https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh
WORKDIR /go/src/github.com/openfaas/faas-cli
COPY . .
# Run a gofmt and exclude all vendored code.
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; }
# ldflags "-s -w" strips binary
# ldflags -X injects commit version into binary
RUN /usr/bin/license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Author(s)" \
&& go test $(go list ./... | grep -v /vendor/ | grep -v /template/|grep -v /build/) -cover \
&& VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli \
&& CGO_ENABLED=0 GOOS=darwin go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli-darwin \
&& CGO_ENABLED=0 GOOS=windows go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli.exe \
&& CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli-armhf \
&& CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli-arm64 \
&& CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build --ldflags "-s -w \
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/openfaas/faas-cli/version.Version=${VERSION}" \
-a -installsuffix cgo -o faas-cli-ppc64le
# Release stage
FROM alpine:3.9
RUN apk --no-cache add ca-certificates git
WORKDIR /root/
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli .
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-darwin .
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-armhf .
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli.exe .
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-arm64 .
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-ppc64le .
ENV PATH=$PATH:/root/
CMD ["faas-cli"]