Skip to content

Commit 449bcac

Browse files
authored
Docker CI build update (#1443)
* Use matrix for docker * Update * Fix * Setup QUEMU for test * Patch-2 * Patch-3 * Patch-4 * Clean up * Fix * Nitpick * missing matrix var for cache
1 parent 455bc94 commit 449bcac

File tree

2 files changed

+47
-136
lines changed

2 files changed

+47
-136
lines changed

.github/workflows/ci-build.yml

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,15 @@ jobs:
175175
name: ledfx-log-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}.log
176176
path: ${{ github.workspace }}/debug_config/ledfx.log
177177

178-
docker-build-amd64:
178+
build-ledfx-docker:
179179
runs-on: ubuntu-latest
180+
strategy:
181+
matrix:
182+
ARCH: ["amd64", "arm64"]
183+
fail-fast: false
180184
env:
181185
IMAGE_NAME: ledfx
182-
ARCH: amd64
183-
name: Build LedFx Docker Image for amd64
186+
name: Build LedFx Docker Image for ${{ matrix.ARCH }}
184187
steps:
185188
- name: Checkout code
186189
uses: actions/checkout@v4
@@ -192,73 +195,29 @@ jobs:
192195
id: repo
193196
run: |
194197
echo "GHCR_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
195-
- name: Build and run for ${{ env.ARCH }}
198+
- name: Build and run for ${{ matrix.ARCH }}
196199
uses: docker/build-push-action@v6
197200
with:
198201
context: ./
199202
file: ./ledfx_docker/Dockerfile
200-
platforms: linux/${{ env.ARCH }}
203+
platforms: linux/${{ matrix.ARCH }}
201204
load: true
202205
push: false
203-
tags: "${{ env.IMAGE_NAME }}:${{ env.ARCH }}"
204-
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
206+
tags: "${{ env.IMAGE_NAME }}:${{ matrix.ARCH }}"
207+
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ matrix.ARCH }}
205208
build-args: |
206209
GITHUB_SHA=${{ github.sha }}
207210
IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}
208211
- name: Run ci-smoke-test
209212
run: |
210-
docker run --name ledfx-run ${{ env.IMAGE_NAME }}:${{ env.ARCH }} --ci-smoke-test -vv -c debug_config --offline
213+
docker run --name ledfx-run-${{ matrix.ARCH }} ${{ env.IMAGE_NAME }}:${{ matrix.ARCH }} --ci-smoke-test -vv -c debug_config --offline
211214
- name: Copy log file from container to workspace
212215
run: |
213-
docker cp ledfx-run:/home/ledfx/debug_config/ledfx.log ${{ github.workspace }}/ledfx.log
214-
docker rm ledfx-run || echo "Container ledfx-run already removed"
216+
docker cp ledfx-run-${{ matrix.ARCH }}:/home/ledfx/debug_config/ledfx.log ${{ github.workspace }}/ledfx.log
217+
docker rm ledfx-run-${{ matrix.ARCH }} || echo "Container ledfx-run already removed"
215218
- name: Attach LedFx test log
216219
uses: actions/upload-artifact@v4
217220
if: always()
218221
with:
219-
name: ledfx-log-${{ runner.os }}-${{ env.IMAGE_NAME }}-${{ env.ARCH }}-docker.log
222+
name: ledfx-log-${{ runner.os }}-${{ env.IMAGE_NAME }}-${{ matrix.ARCH }}-docker.log
220223
path: ${{ github.workspace }}/ledfx.log
221-
222-
docker-build-arm64:
223-
runs-on: ubuntu-latest
224-
env:
225-
IMAGE_NAME: ledfx
226-
ARCH: arm64
227-
name: Build LedFx Docker Image for arm64
228-
steps:
229-
- name: Checkout code
230-
uses: actions/checkout@v4
231-
- name: Set up QEMU (emulation)
232-
uses: docker/setup-qemu-action@v3
233-
- name: Set up Docker Buildx
234-
uses: docker/setup-buildx-action@v3
235-
- name: Lowercase repository owner
236-
id: repo
237-
run: |
238-
echo "GHCR_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
239-
- name: Build and run for ${{ env.ARCH }}
240-
uses: docker/build-push-action@v6
241-
with:
242-
context: ./
243-
file: ./ledfx_docker/Dockerfile
244-
platforms: linux/${{ env.ARCH }}
245-
load: true
246-
push: false
247-
tags: "${{ env.IMAGE_NAME }}:${{ env.ARCH }}"
248-
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
249-
build-args: |
250-
GITHUB_SHA=${{ github.sha }}
251-
IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}
252-
- name: Run ci-smoke-test
253-
run: |
254-
docker run --name ledfx-run ${{ env.IMAGE_NAME }}:${{ env.ARCH }} --ci-smoke-test -vv -c debug_config --offline
255-
- name: Copy log file from container to workspace
256-
run: |
257-
docker cp ledfx-run:/home/ledfx/debug_config/ledfx.log ${{ github.workspace }}/ledfx.log
258-
docker rm ledfx-run || echo "Container ledfx-run already removed"
259-
- name: Attach LedFx test log
260-
uses: actions/upload-artifact@v4
261-
if: always()
262-
with:
263-
name: ledfx-log-${{ runner.os }}-${{ env.IMAGE_NAME }}-${{ env.ARCH }}-docker.log
264-
path: ${{ github.workspace }}/ledfx.log

.github/workflows/test-build-binaries.yml

Lines changed: 33 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -171,68 +171,15 @@ jobs:
171171
name: LedFx-${{ steps.ledfx-version.outputs.ledfx-version }}-osx-arm64
172172
path: ${{ github.workspace }}/dist/*
173173

174-
docker-build-amd64:
175-
name: Build amd64 edge and cache images
174+
build-ledfx-docker:
175+
name: Build LedFx Docker Image for ${{ matrix.ARCH }}
176176
runs-on: ubuntu-latest
177+
strategy:
178+
matrix:
179+
ARCH: ["amd64", "arm64"]
180+
fail-fast: false
177181
env:
178182
IMAGE_NAME: ledfx
179-
ARCH: amd64
180-
steps:
181-
- name: Checkout code
182-
uses: actions/checkout@v4
183-
- name: Set up QEMU (for arm64 emulation)
184-
uses: docker/setup-qemu-action@v3
185-
- name: Set up Docker Buildx
186-
uses: docker/setup-buildx-action@v3
187-
- name: Lowercase repository owner
188-
id: repo
189-
run: |
190-
GHCR_IMAGE="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE_NAME}"
191-
echo "GHCR_IMAGE=${GHCR_IMAGE}" >> $GITHUB_ENV
192-
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == refs/tags/v* ]] && [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then
193-
echo "DOCKER_CACHE_TO=type=registry,ref=${GHCR_IMAGE}:cache-${ARCH},mode=max" >> $GITHUB_ENV
194-
else
195-
echo "DOCKER_CACHE_TO=" >> $GITHUB_ENV
196-
fi
197-
- name: Login to GitHub Container Registry
198-
uses: docker/login-action@v3
199-
with:
200-
registry: ghcr.io
201-
username: ${{ github.actor }}
202-
password: ${{ secrets.GITHUB_TOKEN }}
203-
- name: Build and push image ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }} and ${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
204-
uses: docker/build-push-action@v6
205-
with:
206-
context: ./
207-
file: ./ledfx_docker/Dockerfile
208-
platforms: linux/${{ env.ARCH }}
209-
provenance: false #https://github.com/orgs/community/discussions/45969#discussioncomment-4852744
210-
sbom: false
211-
push: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}
212-
load: true
213-
tags: |
214-
${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}
215-
${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }}
216-
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
217-
cache-to: ${{ env.DOCKER_CACHE_TO }}
218-
build-args: |
219-
GITHUB_SHA=${{ github.sha }}
220-
IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}
221-
- name: Save Docker image as artifact
222-
run: |
223-
docker save ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }} -o image-${{ env.ARCH }}.tar
224-
- name: Upload image artifact
225-
uses: actions/upload-artifact@v4
226-
with:
227-
name: image-${{ env.ARCH }}
228-
path: image-${{ env.ARCH }}.tar
229-
230-
docker-build-arm64:
231-
name: Build arm64 edge and cache images
232-
runs-on: ubuntu-latest
233-
env:
234-
IMAGE_NAME: ledfx
235-
ARCH: arm64
236183
steps:
237184
- name: Checkout code
238185
uses: actions/checkout@v4
@@ -246,7 +193,7 @@ jobs:
246193
GHCR_IMAGE="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE_NAME}"
247194
echo "GHCR_IMAGE=${GHCR_IMAGE}" >> $GITHUB_ENV
248195
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == refs/tags/v* ]] && [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then
249-
echo "DOCKER_CACHE_TO=type=registry,ref=${GHCR_IMAGE}:cache-${ARCH},mode=max" >> $GITHUB_ENV
196+
echo "DOCKER_CACHE_TO=type=registry,ref=${GHCR_IMAGE}:cache-${{ matrix.ARCH }},mode=max" >> $GITHUB_ENV
250197
else
251198
echo "DOCKER_CACHE_TO=" >> $GITHUB_ENV
252199
fi
@@ -256,72 +203,77 @@ jobs:
256203
registry: ghcr.io
257204
username: ${{ github.actor }}
258205
password: ${{ secrets.GITHUB_TOKEN }}
259-
- name: Build and push image ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }} and ${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
206+
- name: Build and push image ${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }} and ${{ env.GHCR_IMAGE }}:cache-${{ matrix.ARCH }}
260207
uses: docker/build-push-action@v6
261208
with:
262209
context: ./
263210
file: ./ledfx_docker/Dockerfile
264-
platforms: linux/${{ env.ARCH }}
211+
platforms: linux/${{ matrix.ARCH }}
265212
provenance: false #https://github.com/orgs/community/discussions/45969#discussioncomment-4852744
266213
sbom: false
267214
push: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}
268215
load: true
269216
tags: |
270-
${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}
271-
${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }}
272-
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ env.ARCH }}
217+
${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }}
218+
${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }}-${{ github.sha }}
219+
cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:cache-${{ matrix.ARCH }}
273220
cache-to: ${{ env.DOCKER_CACHE_TO }}
274221
build-args: |
275222
GITHUB_SHA=${{ github.sha }}
276223
IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}
277224
- name: Save Docker image as artifact
278225
run: |
279-
docker save ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }} -o image-${{ env.ARCH }}.tar
226+
docker save ${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }}-${{ github.sha }} -o image-${{ matrix.ARCH }}.tar
280227
- name: Upload image artifact
281228
uses: actions/upload-artifact@v4
282229
with:
283-
name: image-${{ env.ARCH }}
284-
path: image-${{ env.ARCH }}.tar
285-
docker-test-amd64:
286-
name: Test amd64 image
287-
needs: [docker-build-amd64]
230+
name: image-${{ matrix.ARCH }}
231+
path: image-${{ matrix.ARCH }}.tar
232+
docker-test:
233+
name: Test docker images
234+
needs: [build-ledfx-docker]
288235
runs-on: ubuntu-latest
236+
strategy:
237+
matrix:
238+
ARCH: ["amd64", "arm64"]
239+
fail-fast: false
289240
env:
290241
IMAGE_NAME: ledfx
291-
ARCH: amd64
292242
steps:
293243
- name: Lowercase repository owner
294244
id: repo
295245
run: |
296246
echo "GHCR_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
247+
248+
- name: Set up QEMU (for arm64 emulation)
249+
uses: docker/setup-qemu-action@v3
250+
297251
- name: Download image artifact
298252
uses: actions/download-artifact@v4
299253
with:
300-
name: image-${{ env.ARCH }}
254+
name: image-${{ matrix.ARCH }}
301255
- name: Load Docker image
302-
run: docker load -i image-${{ env.ARCH }}.tar
256+
run: docker load -i image-${{ matrix.ARCH }}.tar
303257
- name: Run test container
304258
run: |
305-
docker run --rm ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }} --ci-smoke-test -vv --offline
259+
docker run --rm ${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }}-${{ github.sha }} --ci-smoke-test -vv --offline
306260
- name: Get LedFx Version
307261
run: |
308-
docker run --rm --entrypoint ledfx ${{ env.GHCR_IMAGE }}:edge-${{ env.ARCH }}-${{ github.sha }} --version | sed 's/LedFx //' > ledfx_version_docker.txt
262+
docker run --rm --entrypoint ledfx ${{ env.GHCR_IMAGE }}:edge-${{ matrix.ARCH }}-${{ github.sha }} --version | sed 's/LedFx //' > ledfx_version_docker.txt
309263
- name: Upload image artifact
310264
uses: actions/upload-artifact@v4
311265
with:
312-
name: ledfx_version_docker
266+
name: ledfx_version_docker-${{ matrix.ARCH }}
313267
path: ledfx_version_docker.txt
314268

315269
docker-publish:
316270
name: Publish docker multiarch image
317-
needs: [docker-build-amd64, docker-build-arm64, docker-test-amd64]
271+
needs: [build-ledfx-docker, docker-test]
318272
runs-on: ubuntu-latest
319273
env:
320274
IMAGE_NAME: ledfx
321275
ARCH: amd64
322276
steps:
323-
# - name: Set up Docker Buildx
324-
# uses: docker/setup-buildx-action@v3
325277
- name: Lowercase repository owner
326278
id: repo
327279
run: |
@@ -335,7 +287,7 @@ jobs:
335287
- name: Download ledfx version docker txt
336288
uses: actions/download-artifact@v4
337289
with:
338-
name: ledfx_version_docker
290+
name: ledfx_version_docker-${{ env.ARCH }}
339291
- name: Get LedFx Version
340292
id: ledfx-version
341293
run: |

0 commit comments

Comments
 (0)