@@ -24,30 +24,38 @@ RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
2424# ldflags -X injects commit version into binary
2525
2626RUN /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 \
3131 -X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
3232 -X github.com/openfaas/faas-cli/version.Version=${VERSION} \
3333 -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 \
3638 -X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
3739 -X github.com/openfaas/faas-cli/version.Version=${VERSION} \
3840 -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 \
4145 -X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
4246 -X github.com/openfaas/faas-cli/version.Version=${VERSION} \
4347 -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 \
4652 -X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
4753 -X github.com/openfaas/faas-cli/version.Version=${VERSION} \
4854 -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 \
5159 -X github.com/openfaas/faas-cli/version.GitCommit=${GIT_COMMIT} \
5260 -X github.com/openfaas/faas-cli/version.Version=${VERSION} \
5361 -X github.com/openfaas/faas-cli/commands.Platform=arm64" \
@@ -64,11 +72,11 @@ RUN addgroup -S app \
6472
6573WORKDIR /home/app
6674
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 .
7280
7381RUN chown -R app:app ./
7482
0 commit comments