@@ -24,30 +24,38 @@ RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
24
24
# ldflags -X injects commit version into binary
25
25
26
26
RUN /usr/bin/license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Author(s)" \
27
- && go test $(go list ./... | grep -v /vendor/ | grep -v /template/|grep -v /build/) -cover \
28
- && VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
29
- && GIT_COMMIT=$(git rev-list -1 HEAD) \
30
- && CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
27
+ && go test $(go list ./... | grep -v /vendor/ | grep -v /template/|grep -v /build/) -cover
28
+
29
+ FROM builder as linux
30
+ RUN CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
31
31
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
32
32
-X github.com/openfaas/faas-cli/version.Version=${VERSION} \
33
33
-X github.com/openfaas/faas-cli/commands.Platform=x86_64" \
34
- -a -installsuffix cgo -o faas-cli \
35
- && CGO_ENABLED=0 GOOS=darwin go build --ldflags "-s -w \
34
+ -a -installsuffix cgo -o faas-cli
35
+
36
+ FROM builder as darwin
37
+ RUN CGO_ENABLED=0 GOOS=darwin go build --ldflags "-s -w \
36
38
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
37
39
-X github.com/openfaas/faas-cli/version.Version=${VERSION} \
38
40
-X github.com/openfaas/faas-cli/commands.Platform=x86_64" \
39
- -a -installsuffix cgo -o faas-cli-darwin \
40
- && CGO_ENABLED=0 GOOS=windows go build --ldflags "-s -w \
41
+ -a -installsuffix cgo -o faas-cli-darwin
42
+
43
+ FROM builder as windows
44
+ RUN CGO_ENABLED=0 GOOS=windows go build --ldflags "-s -w \
41
45
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
42
46
-X github.com/openfaas/faas-cli/version.Version=${VERSION} \
43
47
-X github.com/openfaas/faas-cli/commands.Platform=x86_64" \
44
- -a -installsuffix cgo -o faas-cli.exe \
45
- && CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build --ldflags "-s -w \
48
+ -a -installsuffix cgo -o faas-cli.exe
49
+
50
+ FROM builder as arm
51
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build --ldflags "-s -w \
46
52
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
47
53
-X github.com/openfaas/faas-cli/version.Version=${VERSION} \
48
54
-X github.com/openfaas/faas-cli/commands.Platform=armhf" \
49
- -a -installsuffix cgo -o faas-cli-armhf \
50
- && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --ldflags "-s -w \
55
+ -a -installsuffix cgo -o faas-cli-armhf
56
+
57
+ FROM builder as arm64
58
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --ldflags "-s -w \
51
59
-X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
52
60
-X github.com/openfaas/faas-cli/version.Version=${VERSION} \
53
61
-X github.com/openfaas/faas-cli/commands.Platform=arm64" \
@@ -64,11 +72,11 @@ RUN addgroup -S app \
64
72
65
73
WORKDIR /home/app
66
74
67
- COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli .
68
- COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-darwin .
69
- COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-armhf .
70
- COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli.exe .
71
- COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli-arm64 .
75
+ COPY --from=linux /go/src/github.com/openfaas/faas-cli/faas-cli .
76
+ COPY --from=darwin /go/src/github.com/openfaas/faas-cli/faas-cli-darwin .
77
+ COPY --from=arm /go/src/github.com/openfaas/faas-cli/faas-cli-armhf .
78
+ COPY --from=windows /go/src/github.com/openfaas/faas-cli/faas-cli.exe .
79
+ COPY --from=arm64 /go/src/github.com/openfaas/faas-cli/faas-cli-arm64 .
72
80
73
81
RUN chown -R app:app ./
74
82
0 commit comments