-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.build.tmpl
280 lines (189 loc) · 8.93 KB
/
Dockerfile.build.tmpl
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
FROM docker.io/library/golang:{{ .data.go }} AS go
COPY lib/go.env /usr/local/go/
RUN mkdir -p /build/bin
FROM go AS go_jsonnet
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/google/go-jsonnet/cmd/jsonnet@{{ .data.go_jsonnet }}
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/google/go-jsonnet/cmd/jsonnetfmt@{{ .data.go_jsonnet }}
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/google/go-jsonnet/cmd/jsonnet-deps@{{ .data.go_jsonnet }}
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/google/go-jsonnet/cmd/jsonnet-lint@{{ .data.go_jsonnet }}
FROM go AS wire
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/google/wire/cmd/wire@{{ .data.wire }}
FROM go AS actionlint
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/rhysd/actionlint/cmd/actionlint@{{ .data.actionlint }}
FROM go AS bingo
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/bwplotka/bingo@{{ .data.bingo }}
FROM go AS chglog
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} CGO_ENABLED=0 go install github.com/goreleaser/chglog/cmd/chglog@{{ .data.chglog }}
FROM go AS lefthook
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/evilmartians/lefthook@{{ .data.lefthook }}
FROM go AS dockerfile_json
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN git clone --depth 1 --branch {{ .data.dockerfile_json }} https://github.com/keilerkonzept/dockerfile-json dockerfile-json && \
cd dockerfile-json && \
env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} CGO_ENABLED=0 go install -tags=dfrunsecurity .
FROM go AS enumer
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/dmarkham/enumer@{{ .data.enumer }}
FROM go AS oapi_codegen
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@{{ .data.oapi_codegen }}
FROM go AS protoc_gen_go
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install google.golang.org/protobuf/cmd/protoc-gen-go@{{ .data.protoc_gen_go }}
FROM go AS protoc_gen_go_grpc
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@{{ .data.protoc_gen_go_grpc }}
FROM go AS buf
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/bufbuild/buf/cmd/buf@{{ .data.buf }}
FROM go AS mage
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN git clone --depth 1 --branch {{ .data.mage }} https://github.com/magefile/mage mage && \
cd mage && \
mkdir -p /host/bin /build/bin/${TARGET_GOOS}-${TARGET_GOARCH} && \
env GOPATH=/host go run bootstrap.go && \
env /host/bin/mage -compile /build/bin/${TARGET_GOOS}-${TARGET_GOARCH}/mage -goos ${TARGET_GOOS} -goarch ${TARGET_GOARCH}
FROM go AS migrate
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/golang-migrate/migrate/v4/cmd/migrate@{{ .data.migrate }}
FROM go AS nfpm
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} CGO_ENABLED=0 go install github.com/goreleaser/nfpm/v2/cmd/nfpm@{{ .data.nfpm }}
FROM go AS nilaway
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install go.uber.org/nilaway/cmd/nilaway@{{ .data.nilaway }}
FROM go AS grizzly
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/grafana/grizzly/cmd/grr@{{ .data.grizzly }}
FROM go AS reviewdog
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/reviewdog/reviewdog/cmd/reviewdog@{{ .data.reviewdog }}
FROM go AS semversort
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/whereswaldon/semversort@{{ .data.semversort }}
FROM go AS sqlc
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/sqlc-dev/sqlc/cmd/sqlc@{{ .data.sqlc }}
FROM go AS golangci_lint
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/golangci/golangci-lint/cmd/golangci-lint@{{ .data.golangci_lint }}
FROM go AS gomplate
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/hairyhenderson/gomplate/v4/cmd/gomplate@{{ .data.gomplate }}
FROM go AS gh
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN git clone --depth 1 --branch {{ .data.gh }} https://github.com/cli/cli gh && \
cd gh && \
make script/build && \
env GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} CGO_ENABLED=0 script/build bin/gh && \
mkdir -p /build/bin && \
cp bin/gh /build/bin/gh
FROM go AS git_chglog
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/git-chglog/git-chglog/cmd/git-chglog@{{ .data.git_chglog }}
FROM go AS gotestsum
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install gotest.tools/gotestsum@{{ .data.gotestsum }}
FROM go AS xk6
ARG TARGET_GOOS
ARG TARGET_GOARCH
# The grafana/xk6 image only exists for amd64, so we need to build it for
# the target architecture.
RUN mkdir -p /host/bin /build/bin/${TARGET_GOOS}-${TARGET_GOARCH} && \
env GOPATH=/host go install go.k6.io/xk6/cmd/xk6@{{ .data.xk6 }} && \
env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install go.k6.io/xk6/cmd/xk6@{{ .data.xk6 }}
FROM xk6 AS k6
ARG TARGET_GOOS
ARG TARGET_GOARCH
# The grafana/k6 image only exists for amd64, so we need to build it for
# the architecture we are targeting. The simplest way to build k6 is to
# (ab)use xk6 to build a binary without any extensions. In the future, if
# we wanted additional extensions, this is the place to add them.
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} /host/bin/xk6 build {{ .data.k6 }} --output /build/bin/${TARGET_GOOS}-${TARGET_GOARCH}/k6
FROM go AS yq
ARG TARGET_GOOS
ARG TARGET_GOARCH
RUN env GOPATH=/build GOOS=${TARGET_GOOS} GOARCH=${TARGET_GOARCH} go install github.com/mikefarah/yq/v4@{{ .data.yq }}
FROM docker.io/library/debian:stable-slim AS skopeo
ARG TARGET_GOOS
ARG TARGET_GOARCH
COPY --from=go /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"
RUN apt-get update && \
apt-get install -y \
build-essential \
libgpgme-dev \
libassuan-dev \
libdevmapper-dev \
pkg-config \
git
# skopeo is used to inspect container registries. This can be used to
# inspect the available versions without pulling the repos.
RUN git clone https://github.com/containers/skopeo && \
cd skopeo && \
git checkout "{{ .data.skopeo }}" && \
make GOPATH=/build DISABLE_DOCS=1 bin/skopeo.${TARGET_GOOS}.${TARGET_GOARCH} && \
mkdir -p /build/bin && \
cp bin/skopeo.${TARGET_GOOS}.${TARGET_GOARCH} /build/bin/skopeo
FROM docker.io/library/debian:stable-slim AS final
RUN mkdir -p /dist
COPY --from=actionlint /build/bin/* /dist/
COPY --from=bingo /build/bin/* /dist/
COPY --from=buf /build/bin/* /dist/
COPY --from=chglog /build/bin/* /dist/
COPY --from=dockerfile_json /build/bin/* /dist/
COPY --from=enumer /build/bin/* /dist/
COPY --from=gh /build/bin/* /dist/
COPY --from=git_chglog /build/bin/* /dist/
COPY --from=go_jsonnet /build/bin/* /dist/
COPY --from=golangci_lint /build/bin/* /dist/
COPY --from=gomplate /build/bin/* /dist/
COPY --from=gotestsum /build/bin/* /dist/
COPY --from=grizzly /build/bin/* /dist/
COPY --from=k6 /build/bin/* /dist/
COPY --from=lefthook /build/bin/* /dist/
COPY --from=mage /build/bin/* /dist/
COPY --from=migrate /build/bin/* /dist/
COPY --from=nfpm /build/bin/* /dist/
COPY --from=nilaway /build/bin/* /dist/
COPY --from=oapi_codegen /build/bin/* /dist/
COPY --from=protoc_gen_go /build/bin/* /dist/
COPY --from=protoc_gen_go_grpc /build/bin/* /dist/
COPY --from=reviewdog /build/bin/* /dist/
COPY --from=semversort /build/bin/* /dist/
COPY --from=sqlc /build/bin/* /dist/
COPY --from=skopeo /build/bin/* /dist/
COPY --from=wire /build/bin/* /dist/
COPY --from=xk6 /build/bin/* /dist/
COPY --from=yq /build/bin/* /dist/