-
Notifications
You must be signed in to change notification settings - Fork 33
472 lines (467 loc) · 16 KB
/
build-push.yaml
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
name: Lagoon Image Build
on:
push:
branches:
- 'testing/docker_buildx'
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image_name: commons
context: images/commons
dockerfile: Dockerfile
- image_name: nginx
context: images/nginx
dockerfile: Dockerfile
requires: commons
- image_name: nginx-drupal
context: images/nginx-drupal
dockerfile: Dockerfile
requires: nginx
- image_name: mariadb-10.4
context: images/mariadb
dockerfile: 10.4.Dockerfile
requires: commons
- image_name: mariadb-10.4-drupal
context: images/mariadb-drupal
dockerfile: 10.4.Dockerfile
requires: mariadb-10.4
- image_name: mariadb-10.5
context: images/mariadb
dockerfile: 10.5.Dockerfile
requires: commons
- image_name: mariadb-10.5-drupal
context: images/mariadb-drupal
dockerfile: 10.5.Dockerfile
requires: mariadb-10.5
- image_name: mariadb-10.6
context: images/mariadb
dockerfile: 10.6.Dockerfile
requires: commons
- image_name: mariadb-10.6-drupal
context: images/mariadb-drupal
dockerfile: 10.6.Dockerfile
requires: mariadb-10.6
- image_name: elasticsearch-7
context: images/elasticsearch
dockerfile: 7.Dockerfile
requires: commons
- image_name: logstash-7
context: images/logstash
dockerfile: 7.Dockerfile
requires: commons
- image_name: kibana-7
context: images/kibana
dockerfile: 7.Dockerfile
requires: commons
- image_name: mongo-4
context: images/mongo
dockerfile: 4.Dockerfile
requires: commons
- image_name: node-14
context: images/node
dockerfile: 14.Dockerfile
requires: commons
- image_name: node-14-builder
context: images/node-builder
dockerfile: 14.Dockerfile
requires: node-14
- image_name: node-16
context: images/node
dockerfile: 16.Dockerfile
requires: commons
- image_name: node-16-builder
context: images/node-builder
dockerfile: 16.Dockerfile
requires: node-16
- image_name: node-18
context: images/node
dockerfile: 18.Dockerfile
requires: commons
- image_name: node-18-builder
context: images/node-builder
dockerfile: 18.Dockerfile
requires: node-18
- image_name: python-3.7
context: images/python
dockerfile: 3.7.Dockerfile
requires: commons
- image_name: python-3.8
context: images/python
dockerfile: 3.8.Dockerfile
requires: commons
- image_name: python-3.9
context: images/python
dockerfile: 3.9.Dockerfile
requires: commons
- image_name: python-3.10
context: images/python
dockerfile: 3.10.Dockerfile
requires: commons
- image_name: python-3.11
context: images/python
dockerfile: 3.11.Dockerfile
requires: commons
- image_name: php-8.0-fpm
context: images/php-fpm
dockerfile: 8.0.Dockerfile
requires: commons
- image_name: php-8.0-cli
context: images/php-cli
dockerfile: 8.0.Dockerfile
requires: php-8.0-fpm
- image_name: php-8.0-cli-drupal
context: images/php-cli-drupal
dockerfile: 8.0.Dockerfile
requires: php-8.0-cli
- image_name: php-8.1-fpm
context: images/php-fpm
dockerfile: 8.1.Dockerfile
requires: commons
- image_name: php-8.1-cli
context: images/php-cli
dockerfile: 8.1.Dockerfile
requires: php-8.1-fpm
- image_name: php-8.1-cli-drupal
context: images/php-cli-drupal
dockerfile: 8.1.Dockerfile
requires: php-8.1-cli
- image_name: php-8.2-fpm
context: images/php-fpm
dockerfile: 8.2.Dockerfile
requires: commons
- image_name: php-8.2-cli
context: images/php-cli
dockerfile: 8.2.Dockerfile
requires: php-8.2-fpm
- image_name: php-8.2-cli-drupal
context: images/php-cli-drupal
dockerfile: 8.2.Dockerfile
requires: php-8.2-cli
- image_name: postgres-11
context: images/postgres
dockerfile: 11.Dockerfile
requires: commons
- image_name: postgres-11-drupal
context: images/postgres-drupal
dockerfile: 11.Dockerfile
requires: postgres-11
- image_name: postgres-11-ckan
context: images/postgres-ckan
dockerfile: 11.Dockerfile
requires: postgres-11
- image_name: postgres-12
context: images/postgres
dockerfile: 12.Dockerfile
requires: commons
- image_name: postgres-12-drupal
context: images/postgres-drupal
dockerfile: 12.Dockerfile
requires: postgres-12
- image_name: postgres-13
context: images/postgres
dockerfile: 13.Dockerfile
requires: commons
- image_name: postgres-13-drupal
context: images/postgres-drupal
dockerfile: 13.Dockerfile
requires: postgres-13
- image_name: postgres-14
context: images/postgres
dockerfile: 14.Dockerfile
requires: commons
- image_name: postgres-14-drupal
context: images/postgres-drupal
dockerfile: 14.Dockerfile
requires: postgres-14
- image_name: postgres-15
context: images/postgres
dockerfile: 15.Dockerfile
requires: commons
- image_name: postgres-15-drupal
context: images/postgres-drupal
dockerfile: 15.Dockerfile
requires: postgres-15
- image_name: rabbitmq
context: images/rabbitmq
dockerfile: Dockerfile
requires: commons
- image_name: rabbitmq-cluster
context: images/rabbitmq-cluster
dockerfile: Dockerfile
requires: rabbitmq
- image_name: varnish-6
context: images/varnish
dockerfile: 6.Dockerfile
requires: commons
- image_name: varnish-6-drupal
context: images/varnish-drupal
dockerfile: 6.Dockerfile
requires: varnish-6
- image_name: varnish-6-persistent
context: images/varnish-persistent
dockerfile: 6.Dockerfile
requires: varnish-6
- image_name: varnish-6-persistent-drupal
context: images/varnish-persistent-drupal
dockerfile: 6.Dockerfile
requires: varnish-6-drupal
- image_name: varnish-7
context: images/varnish
dockerfile: 7.Dockerfile
requires: commons
- image_name: varnish-7-drupal
context: images/varnish-drupal
dockerfile: 7.Dockerfile
requires: varnish-7
- image_name: varnish-7-persistent
context: images/varnish-persistent
dockerfile: 7.Dockerfile
requires: varnish-7
- image_name: varnish-7-persistent-drupal
context: images/varnish-persistent-drupal
dockerfile: 7.Dockerfile
requires: varnish-7-drupal
- image_name: solr-7
context: images/solr
dockerfile: 7.Dockerfile
requires: commons
- image_name: solr-7-drupal
context: images/solr-drupal
dockerfile: 7.Dockerfile
requires: solr-7
- image_name: solr-8
context: images/solr
dockerfile: 8.Dockerfile
requires: commons
- image_name: solr-8-drupal
context: images/solr-drupal
dockerfile: 8.Dockerfile
requires: solr-8
- image_name: redis-5
context: images/redis
dockerfile: 5.Dockerfile
requires: commons
- image_name: redis-5-persistent
context: images/redis-persistent
dockerfile: 5.Dockerfile
requires: redis-5
- image_name: redis-6
context: images/redis
dockerfile: 6.Dockerfile
requires: commons
- image_name: redis-6-persistent
context: images/redis-persistent
dockerfile: 6.Dockerfile
requires: redis-6
- image_name: redis-7
context: images/redis
dockerfile: 7.Dockerfile
requires: commons
- image_name: redis-7-persistent
context: images/redis-persistent
dockerfile: 7.Dockerfile
requires: redis-7
- image_name: ruby-3.0
context: images/ruby
dockerfile: 3.0.Dockerfile
requires: commons
- image_name: ruby-3.1
context: images/ruby
dockerfile: 3.1.Dockerfile
requires: commons
- image_name: ruby-3.2
context: images/ruby
dockerfile: 3.2.Dockerfile
requires: commons
- image_name: opensearch-2
context: images/opensearch
dockerfile: 2.Dockerfile
requires: commons
steps:
-
name: Wait for commons upstream
if: ${{ matrix.requires == 'commons' }}
run: sleep 60s
shell: bash
-
name: Wait for non-commons upstream
if: ${{ matrix.image_name != 'commons' && matrix.requires != 'commons' }}
run: sleep 180s
shell: bash
-
name: Wait for dependent builds to succeed
if: ${{ matrix.requires }}
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-regexp: 'build \(${{ matrix.requires }},.?'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 60
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}
labels: |
org.opencontainers.image.authors=The Lagoon Authors
org.opencontainers.image.description=${{ matrix.image_name }} image built for Lagoon
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/lagoon-images/tree/${{ github.ref_name }}/${{ matrix.context }}/${{ matrix.dockerfile }}
org.opencontainers.image.title=${{ github.repository_owner }}/${{ matrix.image_name }}
org.opencontainers.image.url=https://github.com/uselagoon/lagoon-images
tags: |
type=ref,event=branch
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# -
# name: Login to DockerHub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.context }}/${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=docker.io/testlagoon/${{ matrix.image_name }}:main
type=registry,ref=ghcr.io/tobybellwood/${{ matrix.image_name }}:${{ github.ref_name }}
build-args: |
IMAGE_REPO=ghcr.io/${{ github.repository_owner }}
IMAGE_TAG=${{ github.ref_name }}
BUILDKIT_INLINE_CACHE=1
-
uses: anchore/sbom-action@v0
with:
image: ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ github.ref_name }}
artifact-name: ${{ matrix.image_name }}.cyclonedx
format: cyclonedx
-
name: view SBOM
run: |
cat /tmp/sbom-action-*/${{ matrix.image_name }}.cyclonedx
app_test:
runs-on: ubuntu-latest
needs: build
defaults:
run:
working-directory: ./tests
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Checkout
uses: actions/checkout@v4
with:
repository: uselagoon/lagoon-examples
path: tests
-
name: Add additional tests
run: |
git submodule add -b php74 https://github.com/lagoon-examples/drupal9-postgres drupal9-postgres-php74
git submodule add -b php81 https://github.com/lagoon-examples/drupal9-base drupal9-base-php81
-
name: Update git submodules
run: |
git submodule sync
git submodule update --init
-
name: Use built images to test
run: |
grep -rl uselagoon . | xargs sed -i '/^FROM/ s#latest#${{ github.ref_name }}#'
grep -rl uselagoon . | xargs sed -i '/^FROM/ s#uselagoon#ghcr.io/${{ github.repository_owner }}#'
grep -rl uselagoon . | xargs sed -i '/image:/ s#latest#${{ github.ref_name }}#'
grep -rl uselagoon . | xargs sed -i '/image:/ s#uselagoon#ghcr.io/${{ github.repository_owner }}#'
find . -maxdepth 2 -name docker-compose.yml | xargs sed -i -e '/###/d'
-
name: check replacements
run: |
find . -maxdepth 2 -name docker-compose.yml | xargs grep image:
find . -maxdepth 3 -name *.dockerfile | xargs grep ^FROM
-
name: Install test harness
run: |
yarn install
-
name: Generate test files
run: |
yarn generate-tests
-
name: Run docker-compose tests
run: |
yarn test:dockercompose
image_test:
runs-on: ubuntu-latest
needs: build
defaults:
run:
working-directory: ./tests
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Checkout
uses: actions/checkout@v4
with:
repository: uselagoon/lagoon-examples
path: tests
-
name: Add additional tests
run: |
mkdir -p ./all-images && cp ../helpers/docker-compose.yml ./all-images/ && cp ../helpers/TESTING_dockercompose.md ./all-images/
-
name: Use built images to test
run: |
grep -rl uselagoon . | xargs sed -i '/image:/ s#latest#${{ github.ref_name }}#'
grep -rl uselagoon . | xargs sed -i '/image:/ s#uselagoon#ghcr.io/${{ github.repository_owner }}#'
find . -maxdepth 2 -name docker-compose.yml | xargs sed -i -e '/###/d'
-
name: check replacements
run: |
find . -maxdepth 2 -name docker-compose.yml | xargs cat
-
name: check dc builds
run: |
cd ./all-images
docker-compose up -d
docker-compose logs
-
name: Install test harness
run: |
yarn install
-
name: Generate test files
run: |
yarn generate-tests
-
name: Run docker-compose tests
run: |
yarn test:dockercompose