Skip to content

Commit bb14853

Browse files
Minimize docker build (#178)
* Limits Docker operations to only the docker-images.yml workflow (not in builds.yml anymore) * Docker only runs when Docker-related stuff changes * Nightly CI will validate docker builds more regularly (downstream PR)
1 parent f886724 commit bb14853

6 files changed

Lines changed: 430 additions & 552 deletions

File tree

.github/workflows/builds.yml

Lines changed: 0 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -330,256 +330,3 @@ jobs:
330330
else
331331
./build.sh clean-all || true
332332
fi
333-
334-
docker-build-x64:
335-
name: Build (docker-linux-x64)
336-
runs-on: ubuntu-latest
337-
if: github.event_name == 'pull_request'
338-
339-
steps:
340-
- name: Checkout (with submodules)
341-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
342-
with:
343-
submodules: recursive
344-
fetch-depth: 0
345-
346-
- name: Check if Dockerfile.base changed
347-
id: base_changed
348-
shell: bash
349-
run: |
350-
set -euo pipefail
351-
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | grep -q '^docker/Dockerfile\.base$'; then
352-
echo "changed=true" >> "$GITHUB_OUTPUT"
353-
else
354-
echo "changed=false" >> "$GITHUB_OUTPUT"
355-
fi
356-
357-
- name: Free disk space
358-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
359-
with:
360-
tool-cache: false
361-
android: true
362-
dotnet: true
363-
haskell: true
364-
large-packages: true
365-
docker-images: true
366-
swap-storage: true
367-
368-
- name: Pull base image from GHCR
369-
if: steps.base_changed.outputs.changed == 'false'
370-
shell: bash
371-
env:
372-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
373-
run: |
374-
set -euxo pipefail
375-
owner="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
376-
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
377-
docker pull "ghcr.io/${owner}/client-sdk-cpp-base:base-main-amd64"
378-
docker tag "ghcr.io/${owner}/client-sdk-cpp-base:base-main-amd64" \
379-
"livekit-cpp-sdk-base-x64:${{ github.sha }}"
380-
381-
- name: Build base Docker image
382-
if: steps.base_changed.outputs.changed == 'true'
383-
run: |
384-
docker build \
385-
--build-arg TARGETARCH=amd64 \
386-
-t livekit-cpp-sdk-base-x64:${{ github.sha }} \
387-
-f docker/Dockerfile.base \
388-
docker
389-
390-
- name: Build SDK Docker image
391-
run: |
392-
docker build \
393-
--build-arg BASE_IMAGE=livekit-cpp-sdk-base-x64:${{ github.sha }} \
394-
-t livekit-cpp-sdk-x64:${{ github.sha }} \
395-
. \
396-
-f docker/Dockerfile.sdk
397-
398-
- name: Verify installed SDK inside image
399-
run: |
400-
docker run --rm livekit-cpp-sdk-x64:${{ github.sha }} bash -c \
401-
'test -f /opt/livekit-sdk/lib/cmake/LiveKit/LiveKitConfig.cmake'
402-
403-
- name: Save Docker image artifact
404-
run: |
405-
docker save livekit-cpp-sdk-x64:${{ github.sha }} | gzip > livekit-cpp-sdk-x64-docker.tar.gz
406-
407-
- name: Upload Docker image artifact
408-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
409-
with:
410-
name: livekit-cpp-sdk-docker-x64
411-
path: livekit-cpp-sdk-x64-docker.tar.gz
412-
retention-days: 7
413-
414-
docker-build-linux-arm64:
415-
name: Build (docker-linux-arm64)
416-
runs-on: ubuntu-24.04-arm
417-
if: github.event_name == 'pull_request'
418-
419-
steps:
420-
- name: Checkout (with submodules)
421-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
422-
with:
423-
submodules: recursive
424-
fetch-depth: 0
425-
426-
- name: Check if Dockerfile.base changed
427-
id: base_changed
428-
shell: bash
429-
run: |
430-
set -euo pipefail
431-
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | grep -q '^docker/Dockerfile\.base$'; then
432-
echo "changed=true" >> "$GITHUB_OUTPUT"
433-
else
434-
echo "changed=false" >> "$GITHUB_OUTPUT"
435-
fi
436-
437-
- name: Free disk space
438-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
439-
with:
440-
tool-cache: false
441-
android: true
442-
dotnet: true
443-
haskell: true
444-
large-packages: true
445-
docker-images: true
446-
swap-storage: true
447-
448-
- name: Pull base image from GHCR
449-
if: steps.base_changed.outputs.changed == 'false'
450-
shell: bash
451-
env:
452-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
453-
run: |
454-
set -euxo pipefail
455-
owner="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
456-
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
457-
docker pull "ghcr.io/${owner}/client-sdk-cpp-base:base-main-arm64"
458-
docker tag "ghcr.io/${owner}/client-sdk-cpp-base:base-main-arm64" \
459-
"livekit-cpp-sdk-base-arm64:${{ github.sha }}"
460-
461-
- name: Build base Docker image
462-
if: steps.base_changed.outputs.changed == 'true'
463-
run: |
464-
docker build \
465-
--build-arg TARGETARCH=arm64 \
466-
-t livekit-cpp-sdk-base-arm64:${{ github.sha }} \
467-
-f docker/Dockerfile.base \
468-
docker
469-
470-
- name: Build SDK Docker image
471-
run: |
472-
docker build \
473-
--build-arg BASE_IMAGE=livekit-cpp-sdk-base-arm64:${{ github.sha }} \
474-
-t livekit-cpp-sdk:${{ github.sha }} \
475-
. \
476-
-f docker/Dockerfile.sdk
477-
478-
- name: Verify installed SDK inside image
479-
run: |
480-
docker run --rm livekit-cpp-sdk:${{ github.sha }} bash -c \
481-
'test -f /opt/livekit-sdk/lib/cmake/LiveKit/LiveKitConfig.cmake'
482-
483-
- name: Save Docker image artifact
484-
run: |
485-
docker save livekit-cpp-sdk:${{ github.sha }} | gzip > livekit-cpp-sdk-arm64-docker.tar.gz
486-
487-
- name: Upload Docker image artifact
488-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
489-
with:
490-
name: livekit-cpp-sdk-docker-arm64
491-
path: livekit-cpp-sdk-arm64-docker.tar.gz
492-
retention-days: 7
493-
494-
build-collections-linux-arm64:
495-
name: Build (cpp-example-collection-linux-arm64)
496-
runs-on: ubuntu-24.04-arm
497-
needs: docker-build-linux-arm64
498-
if: github.event_name == 'pull_request'
499-
500-
steps:
501-
- name: Checkout
502-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
503-
with:
504-
fetch-depth: 1
505-
506-
# Reclaim ~30GB before loading the multi-GB SDK image and building the
507-
# example collection inside it. Mirrors the docker-build jobs; without it
508-
# the x64 collection build has hit "no space left on device".
509-
- name: Free disk space
510-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
511-
with:
512-
tool-cache: false
513-
android: true
514-
dotnet: true
515-
haskell: true
516-
large-packages: true
517-
docker-images: true
518-
swap-storage: true
519-
520-
- name: Download Docker image artifact
521-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
522-
with:
523-
name: livekit-cpp-sdk-docker-arm64
524-
525-
- name: Load Docker image
526-
run: gzip -dc livekit-cpp-sdk-arm64-docker.tar.gz | docker load
527-
528-
- name: Build cpp-example-collection against installed SDK
529-
run: |
530-
cpp_ex_ref="$(git rev-parse HEAD:cpp-example-collection)"
531-
docker run -e CPP_EX_REF="${cpp_ex_ref}" --rm livekit-cpp-sdk:${{ github.sha }} bash -lc '
532-
set -euxo pipefail
533-
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
534-
cd /tmp/cpp-example-collection
535-
git fetch --depth 1 origin "$CPP_EX_REF"
536-
git checkout "$CPP_EX_REF"
537-
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=/opt/livekit-sdk
538-
cmake --build build --parallel
539-
'
540-
build-collections-x64:
541-
name: Build (cpp-example-collection-x64)
542-
runs-on: ubuntu-latest
543-
needs: docker-build-x64
544-
if: github.event_name == 'pull_request'
545-
546-
steps:
547-
- name: Checkout
548-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
549-
with:
550-
fetch-depth: 1
551-
552-
# Reclaim ~30GB before loading the multi-GB SDK image and building the
553-
# example collection inside it. The standard ubuntu-latest runner has hit
554-
# "no space left on device" here without this step.
555-
- name: Free disk space
556-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
557-
with:
558-
tool-cache: false
559-
android: true
560-
dotnet: true
561-
haskell: true
562-
large-packages: true
563-
docker-images: true
564-
swap-storage: true
565-
566-
- name: Download Docker image artifact
567-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
568-
with:
569-
name: livekit-cpp-sdk-docker-x64
570-
571-
- name: Load Docker image
572-
run: gzip -dc livekit-cpp-sdk-x64-docker.tar.gz | docker load
573-
574-
- name: Build cpp-example-collection against installed SDK
575-
run: |
576-
cpp_ex_ref="$(git rev-parse HEAD:cpp-example-collection)"
577-
docker run -e CPP_EX_REF="${cpp_ex_ref}" --rm livekit-cpp-sdk-x64:${{ github.sha }} bash -lc '
578-
set -euxo pipefail
579-
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
580-
cd /tmp/cpp-example-collection
581-
git fetch --depth 1 origin "$CPP_EX_REF"
582-
git checkout "$CPP_EX_REF"
583-
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=/opt/livekit-sdk
584-
cmake --build build --parallel
585-
'

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
docs: ${{ steps.filter.outputs.docs }}
2828
cpp_checks: ${{ steps.filter.outputs.cpp_checks }}
2929
rust_release_check: ${{ steps.filter.outputs.rust_release_check }}
30+
docker: ${{ steps.filter.outputs.docker }}
3031
steps:
3132
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
3233
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
@@ -41,7 +42,6 @@ jobs:
4142
- cpp-example-collection/**
4243
- client-sdk-rust/**
4344
- cmake/**
44-
- docker/**
4545
- CMakeLists.txt
4646
- CMakePresets.json
4747
- build*
@@ -84,6 +84,10 @@ jobs:
8484
- .clang-tidy
8585
- .github/workflows/ci.yml
8686
- .github/workflows/cpp-checks.yml
87+
docker:
88+
- docker/**
89+
- .github/workflows/ci.yml
90+
- .github/workflows/docker-images.yml
8791
rust_release_check:
8892
- client-sdk-rust
8993
@@ -94,6 +98,19 @@ jobs:
9498
uses: ./.github/workflows/builds.yml
9599
secrets: inherit
96100

101+
docker-images:
102+
name: Docker Images
103+
needs: changes
104+
if: ${{ (github.event_name == 'pull_request' && needs.changes.outputs.docker == 'true') || github.event_name == 'workflow_dispatch' }}
105+
permissions:
106+
contents: read
107+
actions: read
108+
packages: write
109+
uses: ./.github/workflows/docker-images.yml
110+
with:
111+
push_images: false
112+
secrets: inherit
113+
97114
tests:
98115
name: Tests
99116
needs: changes
@@ -142,6 +159,7 @@ jobs:
142159
needs:
143160
- changes
144161
- builds
162+
- docker-images
145163
- tests
146164
- license-check
147165
- cpp-checks

0 commit comments

Comments
 (0)