-
Notifications
You must be signed in to change notification settings - Fork 17
/
config.yml
307 lines (303 loc) · 9.65 KB
/
config.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
version: 2.1
commands:
dockerhub-store:
description: "store an image on Dockerhub"
parameters:
tag:
description: "image tag (full variant name) to be saved"
type:
string
steps:
- run:
name: Login to Docker Hub
command: echo "$DOCKERHUB_PASS" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- run:
name: save image
command: |
docker tag ocrd/all:<< parameters.tag >> ocrd/all:<< parameters.tag >>-${CIRCLE_SHA1}
docker push ocrd/all:<< parameters.tag >>-${CIRCLE_SHA1}
no_output_timeout: 30m
dockerhub-load:
description: "load an image from Dockerhub"
parameters:
tag:
description: "image tag (full variant name) to be pulled"
type:
string
steps:
- run:
name: load previous image
command: |
docker pull ocrd/all:<< parameters.tag >>-${CIRCLE_SHA1}
docker tag ocrd/all:<< parameters.tag >>-${CIRCLE_SHA1} ocrd/all:<< parameters.tag >>
dockerhub-remove:
description: "remove an image on Dockerhub"
parameters:
tag:
description: "image tag (full variant name) to be removed"
type:
string
steps:
- run:
name: use Dockerhub API to remove temporary image
command: |
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKERHUB_USERNAME\", \"password\": \"$DOCKERHUB_PASS\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
set -x
curl -i -X DELETE -H "Accept: application/json" -H "Authorization: JWT $HUB_TOKEN" https://hub.docker.com/v2/namespaces/ocrd/repositories/all/tags/<< parameters.tag >>-${CIRCLE_SHA1}/
# must be unconditional (both on_error and on_success)
when: always
build:
description: "template for all docker-* build jobs"
parameters:
tag:
description: "image tag (full variant name) to be built"
type:
string
dep:
description: "image tag (full variant name) this depends on (should _not_ be rebuilt)"
type:
string
default: "core"
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: make docker-<< parameters.tag >> -o docker-<< parameters.dep >> GIT_DEPTH=--single-branch
no_output_timeout: 30m
- run:
name: test image
command: |
mkdir test-results
# cannot use docker run -v because the docker executor does not support volumes
# docker run --rm -v $PWD:/data ocrd/all:<< parameters.tag >> make -C /build/core deps-test test PYTEST_ARGS=--junitxml=/data/test-results/core.xml
id=`docker create ocrd/all:<< parameters.tag >> make -C /build/core deps-test test PYTEST_ARGS=--junitxml=core.xml`
docker start -a $id
docker cp $id:/build/core/core.xml test-results/
docker rm $id
- store_test_results:
path: test-results/core.xml
deploy:
description: "template for all docker-* deploy jobs"
parameters:
tag:
description: "image tag (full variant name) to be pushed"
type:
string
steps:
- checkout
- setup_remote_docker
- run:
name: Alias Docker image
command: docker tag ocrd/all:<< parameters.tag >> ocrd/all:<< parameters.tag >>-git
- run:
name: Login to Docker Hub
command: echo "$DOCKERHUB_PASS" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- run:
name: Push images to Docker Hub
no_output_timeout: 2.5h
command: |
docker push ocrd/all:<< parameters.tag >>
docker push ocrd/all:<< parameters.tag >>-git
- when:
condition:
equal: [ maximum, << parameters.tag >> ]
steps:
- run:
name: store ocrd-all-tool.json
command: |
id=`docker create ocrd/all:maximum`
docker cp $id:/build/ocrd-all-tool.json .
- store_artifacts:
path: ocrd-all-tool.json
destination: ocrd-all-tool.json
- run:
name: store ocrd-all-module-dir.json
command: |
id=`docker create ocrd/all:maximum`
docker cp $id:/build/ocrd-all-module-dir.json .
- store_artifacts:
path: ocrd-all-module-dir.json
destination: ocrd-all-module-dir.json
- when:
condition:
equal: [ maximum-cuda, << parameters.tag >> ]
steps:
- run:
name: Create a date-versioned mirror of ocrd/all:maximum-cuda
command: bash release.sh release-dockerhub
- run:
name: Update badge
command: curl -X POST "$MICROBADGER_WEBHOOK" || true
- when:
# takes too long for 1h1m CircleCI timeout overall
# also, storage is limited...
condition: false
steps:
- run:
name: persist image
command: |
sudo apt install pigz
docker image save ocrd/all:<< parameters.tag >> | pigz --fast > ocrd-all-maximum.tar.gz
no_output_timeout: 30m
# can be downloaded from CircleCI.com and imported via "docker image load"
- store_artifacts:
path: ocrd-all-maximum.tar.gz
destination: artifacts
jobs:
build-mini:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- build:
tag: minim<< parameters.variant >>
- dockerhub-store:
tag: minim<< parameters.variant >>
build-medi:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- dockerhub-load:
tag: minim<< parameters.variant >>
- unless:
condition:
equal: [ master, << pipeline.git.branch >>]
# only PR testing – not needed anymore
steps:
- dockerhub-remove:
tag: minim<< parameters.variant >>
- build:
dep: minim<< parameters.variant >>
tag: medi<< parameters.variant >>
- dockerhub-store:
tag: medi<< parameters.variant >>
build-maxi:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- dockerhub-load:
tag: medi<< parameters.variant >>
- unless:
condition:
equal: [ master, << pipeline.git.branch >>]
# only PR testing – not needed anymore
steps:
- dockerhub-remove:
tag: medi<< parameters.variant >>
- build:
dep: medi<< parameters.variant >>
tag: maxim<< parameters.variant >>
- when:
condition:
equal: [ master, << pipeline.git.branch >>]
# only PR testing – not needed
steps:
- dockerhub-store:
tag: maxim<< parameters.variant >>
deploy-mini:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- dockerhub-load:
tag: minim<< parameters.variant >>
- deploy:
tag: minim<< parameters.variant >>
- dockerhub-remove:
tag: minim<< parameters.variant >>
deploy-medi:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- dockerhub-load:
tag: medi<< parameters.variant >>
- deploy:
tag: medi<< parameters.variant >>
- dockerhub-remove:
tag: medi<< parameters.variant >>
deploy-maxi:
docker:
- image: cimg/base:current-22.04
parameters:
variant:
type:
string
steps:
- dockerhub-load:
tag: maxim<< parameters.variant >>
- deploy:
tag: maxim<< parameters.variant >>
- dockerhub-remove:
tag: maxim<< parameters.variant >>
workflows:
version: 2
build:
jobs:
- build-mini:
name: build-minim<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
- build-medi:
name: build-medi<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
requires:
- build-minim<< matrix.variant >>
- build-maxi:
name: build-maxim<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
requires:
- build-medi<< matrix.variant >>
- deploy-mini:
name: deploy-minim<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
requires:
- build-minim<< matrix.variant >>
filters:
branches:
only: master
- deploy-medi:
name: deploy-medi<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
requires:
- build-medi<< matrix.variant >>
filters:
branches:
only: master
- deploy-maxi:
name: deploy-maxim<< matrix.variant >>
matrix:
parameters:
variant: [um, um-cuda]
requires:
- build-maxim<< matrix.variant >>
filters:
branches:
only: master