-
Notifications
You must be signed in to change notification settings - Fork 34
270 lines (265 loc) · 8.2 KB
/
build-push-buildx.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
name: Lagoon Image Build - buildx
on:
push:
branches:
- 'testing-docker_buildx**'
pull_request:
branches:
- 'testing-docker_buildx**'
jobs:
changes:
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'package_group' output variable
package_group: ${{ steps.filter.outputs.changes }}
steps:
-
name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
mariadb:
- 'images/mariadb/**'
- '!images/**'
node:
- 'images/node/**'
- '!images/**'
php:
- 'images/php/**'
- '!images/**'
postgres:
- 'images/postgres/**'
- '!images/**'
python:
- 'images/python/**'
- '!images/**'
redis:
- 'images/redis/**'
- '!images/**'
ruby:
- 'images/ruby/**'
- '!images/**'
solr:
- 'images/solr/**'
- '!images/**'
varnish:
- 'images/varnish/**'
- '!images/**'
others:
- 'images/commons/**'
- 'images/elasticsearch-7/**'
- 'images/kibana-7/**'
- 'images/logstash-7/**'
- 'images/mongo-4/**'
- 'images/nginx/**'
- 'images/nginx-drupal/**'
- 'images/opensearch-2/**'
- 'images/rabbitmq/**'
- 'images/rabbitmq-cluster/**'
- '!images/**'
build:
needs: changes
strategy:
fail-fast: false
matrix:
package_group: ${{ fromJSON(needs.changes.outputs.package_group) }}
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# -
# name: Restore docker cache
# id: cache-packages-restore
# uses: actions/cache/restore@v3
# with:
# path: |
# /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ matrix.package_group }}
-
name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.package_group }}-${{ hashFiles('**/images') }}
restore-keys: |
${{ runner.os }}-buildx-
# -
# 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
uses: docker/bake-action@v4
env:
PUSH_REPO: ghcr.io/${{ github.repository_owner }}
PUSH_TAG: testing--docker-buildx
PLATFORMS: linux/amd64,linux/arm64
with:
files: |
./docker-bake.hcl
targets: ${{ matrix.package_group }}
push: true
# set: |
# *.cache-from=type=gha
# *.cache-to=type=gha,mode=max
set: |
*.cache-from=type=local,src=/tmp/.buildx-cache
*.cache-to=type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# -
# name: Save docker cache
# uses: actions/cache/save@v3
# with:
# path: |
# /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ matrix.package_group }}-${{ hashFiles('**/images') }}
# -
# 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 }}
# type=gha
# cache-to: |
# type=gha,mode=max
# 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