-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
365 lines (319 loc) · 11.2 KB
/
Taskfile.yml
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
---
version: '3'
env:
RELEASES: ( "3.9.6" "3.10.9" "3.11.13" "3.12.12" "3.13.12" "3.14.10" "3.15.11" "3.16.9" "3.17.7" "3.18.6" "3.19.1" )
ARCHITECTURES: ( "x86_64" "aarch64" "armhf" )
OWNER: "troyfontaine"
REPOSITORY: "alpinelinux"
CDN: "https://dl-cdn.alpinelinux.org/alpine"
tasks:
build-test-local:
desc: Build images to test locally
cmds:
- task: get-signingkey
- task: create-buildx-builder
- task: get-rootfs
- task: build-local
- task: test-images
- task: cleanup
build-test-gha:
desc: Build images to test via GHA
cmds:
- task: get-signingkey
- task: get-rootfs
- task: build-gha
- task: test-images
build-release:
desc: Build images to push to Dockerhub and create multi-arch manifest
cmds:
- task: get-signingkey
- task: get-rootfs
- task: build-and-push
- task: create-manifest
- task: cleanup
build-release-gha:
desc: Build images to test via GHA
cmds:
- task: get-signingkey
- task: get-rootfs
- task: build-and-push-gha
- task: create-manifest
create-buildx-builder:
desc: Setup
cmds:
- |
docker buildx create --name alpinebuilder \
--platform linux/arm64,linux/amd64,linux/armhf \
--driver docker-container --use
get-signingkey:
desc: Get the Alpine signing key
cmds:
- curl -s https://alpinelinux.org/keys/ncopa.asc | gpg --import -
get-rootfs:
desc: Download the minirootfs file system \
for the various platforms to be used in \
building docker container images.
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
mkdir -p "./filesystem/$version"
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
fi
mkdir -p "./filesystem/$version/$target_arch"
URI_PATH="alpine-minirootfs-${release}-${arch}.tar.gz"
# Grab our root file system
if ! wget -q -O \
"./filesystem/${version}/$target_arch/alpine.tar.gz" \
"{{ .CDN }}/v${version}/releases/${arch}/${URI_PATH}"; then
echo "Failed to download version ${version} for arch ${arch}"
fi
# Grab the signature for the file
if ! wget -q -O \
"./filesystem/${version}/$target_arch/key.asc" \
"{{ .CDN }}/v${version}/releases/${arch}/${URI_PATH}.asc"; then
echo "Failed to download signature file version ${version} for arch ${arch}"
fi
# Validate the downloaded root file system
if ! gpg --verify "./filesystem/${version}/$target_arch/key.asc"\
"./filesystem/${version}/$target_arch/alpine.tar.gz"; then
echo "GPG Verification Failed! Exiting"
exit 1
fi
done
done
build-local:
desc: Build container images using the downloaded minirootfs tar balls
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
fi
arch="$target_arch" \
workingdir={{ .WORKINGDIR }} \
release="$release" \
version="$version" \
owner={{ .OWNER }} \
repository={{ .REPOSITORY }} \
docker buildx bake \
--set container.context="./filesystem/$version/$target_arch/" \
--set container.platform="linux/$target_arch" \
--set container.args.VCS_REF={{ .VCS_REF }} \
--set container.args.BUILD_DATE={{ .BUILD_DATE }} \
--set container.args.ALPINE_VERSION=$release \
--set container.args.VERSION=$version \
--load
done
done
vars:
VCS_REF: $(git rev-parse --short HEAD)
BUILD_DATE: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
WORKINGDIR: $(echo $PWD)
build-gha:
desc: Build container images using the downloaded minirootfs tar balls
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
fi
arch="$target_arch" \
workingdir=$GITHUB_WORKSPACE \
release="$release" \
version="$version" \
owner={{ .OWNER }} \
repository={{ .REPOSITORY }} \
docker buildx bake \
--set container.context="./filesystem/$version/$target_arch/" \
--set container.platform="linux/$target_arch" \
--set container.args.VCS_REF={{ .VCS_REF }} \
--set container.args.BUILD_DATE={{ .BUILD_DATE }} \
--set container.args.ALPINE_VERSION=$release \
--set container.args.VERSION=$version \
--load
done
done
vars:
VCS_REF: $(git rev-parse --short HEAD)
BUILD_DATE: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
test-images:
desc: Run tests against the local images
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
alpine_arch="x86_64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
alpine_arch="aarch64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
alpine_arch="armv7l"
fi
docker tag \
{{ .OWNER }}/{{ .REPOSITORY }}:$target_arch-$version \
{{ .OWNER }}/{{ .REPOSITORY }}:test-candidate
TARGET_ARCH=$target_arch \
ARCH=$arch \
ALPINE_ARCH=$alpine \
VERSION=$version \
OWNER={{ .OWNER }} \
REPOSITORY={{ .REPOSITORY }} \
RELEASE=$release \
./test/bats/bin/bats test.bats
docker image rm \
{{ .OWNER }}/{{ .REPOSITORY }}:test-candidate \
>/dev/null 2>&1
done
done
build-and-push:
desc: Build container images using the downloaded minirootfs tar balls
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
fi
arch="$target_arch" \
workingdir={{ .WORKINGDIR }} \
release="$release" \
version="$version" \
owner={{ .OWNER }} \
repository={{ .REPOSITORY }} \
docker buildx bake \
--set container.context="./filesystem/$version/$target_arch/" \
--set container.platform="linux/$target_arch" \
--set container.args.VCS_REF={{ .VCS_REF }} \
--set container.args.BUILD_DATE={{ .BUILD_DATE }} \
--set container.args.ALPINE_VERSION=$release \
--set container.args.VERSION=$version \
--push
done
done
vars:
VCS_REF: $(git rev-parse --short HEAD)
BUILD_DATE: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
WORKINGDIR: $(echo $PWD)
build-and-push-gha:
desc: Build container images using the downloaded minirootfs tar balls
cmds:
- |
set -e
releases={{ .RELEASES }}
architectures={{ .ARCHITECTURES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
for arch in "${architectures[@]}"
do
if [ "$arch" == "x86_64" ]; then
target_arch="amd64"
elif [ "$arch" == "aarch64" ]; then
target_arch="arm64"
elif [ "$arch" == "armhf" ]; then
target_arch="$arch"
fi
arch="$target_arch" \
workingdir=$GITHUB_WORKSPACE \
release="$release" \
version="$version" \
owner={{ .OWNER }} \
repository={{ .REPOSITORY }} \
docker buildx bake \
--set container.context="./filesystem/$version/$target_arch/" \
--set container.platform="linux/$target_arch" \
--set container.args.VCS_REF={{ .VCS_REF }} \
--set container.args.BUILD_DATE={{ .BUILD_DATE }} \
--set container.args.ALPINE_VERSION=$release \
--set container.args.VERSION=$version \
--push
done
done
vars:
VCS_REF: $(git rev-parse --short HEAD)
BUILD_DATE: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
create-manifest:
desc: Create the multi-arch manifest
cmds:
- |
set -e
releases={{ .RELEASES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
docker buildx imagetools create \
-t "{{ .OWNER }}/{{ .REPOSITORY }}:${release}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:amd64-${release}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:arm64-${release}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:armhf-${release}"
docker buildx imagetools create \
-t "{{ .OWNER }}/{{ .REPOSITORY }}:${version}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:amd64-${version}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:arm64-${version}" \
"{{ .OWNER }}/{{ .REPOSITORY }}:armhf-${version}"
done
cleanup:
desc: Clean-up downloaded tar balls
cmds:
- |
set -e
releases={{ .RELEASES }}
for release in "${releases[@]}"
do
version=$(echo "$release" | cut -f1,2 -d'.' )
rm -rf "./filesystem/$version"
done
docker buildx rm alpinebuilder || true