-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·77 lines (72 loc) · 2.34 KB
/
build.sh
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
#!/bin/bash
if [[ -f .url ]]; then
URL=$(cat .url)
fi
if [[ $URL == "" ]]; then
URL=https://registry.hub.docker.com/v2/repositories/minio/minio/tags
fi
while [[ $URL != "" ]]; do
echo $URL > .url
exitCode=1
while [[ $exitCode != 0 ]]; do
content=$(curl -s $URL)
exitCode=$?
echo "$exitCode - $URL"
done
URL=$(
echo $content | \
grep -oE '"next":"https://registry.hub.docker.com/v2/[^"]+"' | \
sed -e 's/^"next":"//' | \
sed -e 's/"$//' | \
sed -e 's/\\u0026/\&/'
)
tags=$(
echo $content | \
grep -oE '"name":"[^"]+"' | \
sed -e 's/^"name":"//' | \
sed -e 's/"$//' | \
grep -vE "^edge.*" | \
grep -vE '^\d{4,}-.*'
)
for tag in $tags; do
exitCode=1
while [[ $exitCode != 0 ]]; do
content=$(curl -s https://registry.hub.docker.com/v2/repositories/minio/minio/tags/$tag)
exitCode=$?
echo "$exitCode - https://registry.hub.docker.com/v2/repositories/minio/minio/tags/$tag"
done
platforms=$(
echo $content | \
grep -oE '"architecture":"[^"]+"' | \
sed -e 's/^"architecture":"//' | \
sed -e 's/"$//' | \
sed -e 's/^/linux\//' | \
grep -vE '/unknown$' | \
tr '\n' ',' | \
sed -e 's/,$//'
)
digestCurrent=$(
echo $content | \
grep -oE '"digest":"[^"]+"' | \
sed -e 's/^"digest":"//' | \
sed -e 's/"$//'
)
digestOld=$(cat hashes/$tag 2> /dev/null)
if [[ "$(echo "$digestCurrent" | sort)" != "$(echo "$digestOld" | sort)" ]] && [[ $digestCurrent != "" ]] || [[ -f hashes/$tag.error ]] || [[ -f "hashes/${tag}@error" ]]; then
echo "FROM minio/minio:${tag}" > Dockerfile && \
cat Dockerfile.template >> Dockerfile && \
docker buildx build \
--builder minio-server \
--platform $platforms \
-t satantime/minio-server:$tag --push . && \
rm Dockerfile && \
printf '%s\n' $digestCurrent > hashes/$tag && \
git add --all && \
git commit -m "Update of ${tag} on $(date +%Y-%m-%d)" && \
sleep 0;
fi
sleep 0;
done;
sleep 0;
done
rm .url