-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
206 lines (182 loc) · 5.78 KB
/
.gitlab-ci.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
stages:
- multiarch
- prepare
- build
- pack
variables:
alpine_base_image: "reg.git.brickburg.de/bbcontainers/hub/alpine:3"
alpine_base_image_own: "$CI_REGISTRY_IMAGE/alpine_base_amd64:latest"
cpuparallel: 2
.tpl:docker:
image: reg.git.brickburg.de/bbcontainers/hub/docker:bb-stable-buildx
tags:
- docker
- gitrunner-einbeck01
.tpl:stable:
extends: .tpl:docker
only:
- master
.tpl:matrixbuild:
extends: .tpl:stable
parallel:
matrix:
- ARCH: 'x86'
BASEIMAGE: reg.git.brickburg.de/bbcontainers/hub/i386/alpine:3
OWNBASEIMAGE: "$CI_REGISTRY_IMAGE/alpine_base_x86:latest"
- ARCH: 'amd64'
BASEIMAGE: "$alpine_base_image"
OWNBASEIMAGE: "$alpine_base_image_own"
- ARCH: 'aarch64'
BASEIMAGE: reg.git.brickburg.de/bbcontainers/hub/arm64v8/alpine:3
OWNBASEIMAGE: "$CI_REGISTRY_IMAGE/alpine_base_aarch64:latest"
- ARCH: 'armv7'
BASEIMAGE: reg.git.brickburg.de/bbcontainers/hub/arm32v7/alpine:3
OWNBASEIMAGE: "$CI_REGISTRY_IMAGE/alpine_base_armv7:latest"
.tpl:defaultalpinebuild:
stage: build
extends: .tpl:matrixbuild
script:
# build
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- cd src/$containerfolder
- docker buildx build --cache-from "$uidimage" --cache-to type=inline -t "$uidimage" --build-arg ARCH=$ARCH --build-arg BASEIMAGE=$OWNBASEIMAGE --build-arg PARALLEL=$cpuparallel .
- cd ../../
# extract binary
- docker run -d --rm --name "$uidname" "$uidimage" /bin/sleep 300
- sleep 3
- docker cp $uidname:/dist .
- docker stop $uidname
- sleep 3
- docker image rm "$uidimage"
artifacts:
paths:
- dist/
variables:
uidimage: "staticbuild_${CI_JOB_ID}:latest"
uidname: "staticbuild_${CI_JOB_ID}"
multiarch:enable:
stage: multiarch
extends: .tpl:stable
script:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
prepare:baseimages:
stage: prepare
extends: .tpl:matrixbuild
script:
- cd src/base-alpine
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker buildx build --cache-from "${OWNBASEIMAGE}" --cache-to type=inline -t "$OWNBASEIMAGE" --build-arg BASEIMAGE=$BASEIMAGE .
- docker push "$OWNBASEIMAGE"
build:busybox:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: busybox
build:tcpdump:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: tcpdump
build:curl:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: curl
build:vim:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: vim
build:iperf2:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: iperf2
build:iperf3:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: iperf3
build:dig:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: dig
build:jq:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: jq
build:rsync:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: rsync
build:ssh:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: ssh
build:htop:
stage: build
extends: .tpl:defaultalpinebuild
variables:
containerfolder: htop
pack:pack:
stage: pack
extends: .tpl:stable
image: "$alpine_base_image_own"
script:
- ls -lisah dist/
# create all-in-one package for x86
- mkdir serverless.industries-static-binaries.x86
- cp dist/*.x86 serverless.industries-static-binaries.x86
- tar cvzf dist/all.x86.tar.gz serverless.industries-static-binaries.x86
# create all-in-one package for amd64
- mkdir serverless.industries-static-binaries.amd64
- cp dist/*.amd64 serverless.industries-static-binaries.amd64
- tar cvzf dist/all.amd64.tar.gz serverless.industries-static-binaries.amd64
# create all-in-one package for aarch64
- mkdir serverless.industries-static-binaries.aarch64
- cp dist/*.aarch64 serverless.industries-static-binaries.aarch64
- tar cvzf dist/all.aarch64.tar.gz serverless.industries-static-binaries.aarch64
# create all-in-one package for armv7
- mkdir serverless.industries-static-binaries.armv7
- cp dist/*.armv7 serverless.industries-static-binaries.armv7
- tar cvzf dist/all.armv7.tar.gz serverless.industries-static-binaries.armv7
# create info.txt
- cd dist
- rm -f info.txt
- echo "# Static self-containing builds of some system utilities" >> info.txt
- echo "# Build at the $(date) by Christian Blechert <christian@serverless.industries>" >> info.txt
- echo >> info.txt
- |
while read name; do
bname=$(basename "$name")
md5=$(md5sum $name | awk '{print $1}')
sha1=$(sha1sum $name | awk '{print $1}')
sha256=$(sha256sum $name | awk '{print $1}')
sha512=$(sha512sum $name | awk '{print $1}')
info=$(file $name)
versionfile=".version-$bname"
if [ -f "$versionfile" ]; then
echo "$bname: version: $(cat "$versionfile")" >> info.txt
fi
echo "$bname: file: $info" >> info.txt
echo "$bname: md5sum: $md5" >> info.txt
echo "$bname: sha1sum: $sha1" >> info.txt
echo "$bname: sha256sum: $sha256" >> info.txt
echo "$bname: sha512sum: $sha512" >> info.txt
echo >> info.txt
done <<< "$(find . -type f ! -iname '.version-*' ! -iname '*.txt' | sort)"
- cat info.txt
- rm .version*
- cd ..
# upload
- |
lftp -d --norc <<EOF
set ftp:ssl-force true
open -u ${FTP_USER},${FTP_PASSWORD} ftp://${FTP_HOST}
mirror --reverse --delete-first --delete dist/ $FTP_DIR
exit
EOF