-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.redist
More file actions
97 lines (72 loc) · 3.72 KB
/
Copy pathDockerfile.redist
File metadata and controls
97 lines (72 loc) · 3.72 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
FROM ghcr.io/openfaas/license-check:0.4.1 as license-check
# Build stage
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.20 as builder
ARG GIT_COMMIT
ARG VERSION
ENV GO111MODULE=on
ENV GOFLAGS=-mod=vendor
ENV CGO_ENABLED=0
WORKDIR /usr/bin/
COPY --from=license-check /license-check /usr/bin/
WORKDIR /go/src/github.com/forge4flow/forge-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 "BoiseITGuru" "Forge4Flow Author(s)" "Forge4Flow DAO LLC" \
# && go test $(go list ./... | grep -v /vendor/ | grep -v /template/|grep -v /build/) -cover
RUN /usr/bin/license-check -path ./ --verbose=false "BoiseITGuru" "Forge4Flow Author(s)" "Forge4Flow DAO LLC"
FROM builder as linux
RUN CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=x86_64" \
-o forge-cli
FROM builder as darwin
RUN CGO_ENABLED=0 GOOS=darwin go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=x86_64" \
-o forge-cli-darwin
FROM builder as darwin-arm64
RUN CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=arm64" \
-o forge-cli-darwin-arm64
FROM builder as windows
RUN CGO_ENABLED=0 GOOS=windows go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=x86_64" \
-o forge-cli.exe
FROM builder as arm
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=armhf" \
-o forge-cli-armhf
FROM builder as arm64
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --ldflags "-s -w \
-X github.com/forge4flow/forge-cli/version.GitCommit=${GIT_COMMIT} \
-X github.com/forge4flow/forge-cli/version.Version=${VERSION} \
-X github.com/forge4flow/forge-cli/commands.Platform=arm64" \
-o forge-cli-arm64
# Release stage
FROM alpine:3.18 as release
RUN apk --no-cache add ca-certificates git
RUN addgroup -S app \
&& adduser -S -g app app \
&& apk add --no-cache ca-certificates
WORKDIR /home/app
COPY --from=linux /go/src/github.com/forge4flow/forge-cli/forge-cli .
COPY --from=darwin /go/src/github.com/forge4flow/forge-cli/forge-cli-darwin .
COPY --from=darwin-arm64 /go/src/github.com/forge4flow/forge-cli/forge-cli-darwin-arm64 .
COPY --from=arm /go/src/github.com/forge4flow/forge-cli/forge-cli-armhf .
COPY --from=windows /go/src/github.com/forge4flow/forge-cli/forge-cli.exe .
COPY --from=arm64 /go/src/github.com/forge4flow/forge-cli/forge-cli-arm64 .
RUN chown -R app:app ./
ENV PATH=$PATH:/home/app/
USER app
CMD ["forge-cli"]