Skip to content

Commit

Permalink
Add workflow action to create multi image manifest (#583)
Browse files Browse the repository at this point in the history
Now that we are building the gstreamer images for different architectures on different workers, each architecture image being pushed overwrites the other one, resulting in image tags with only one architecture.

In order to fix this, this PR renames the images created by each worker by appending an arch suffix to the tag. This then adds a GH action to be run manually after all images are built, to manually create a multi arch manifest that references the arch specific tags.
  • Loading branch information
biglittlebigben authored Jan 15, 2024
1 parent 8d0ab0d commit e8a71ff
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish-gstreamer-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ jobs:
gstreamer-build-amd64:
uses: ./.github/workflows/publish-gstreamer-base.yaml
with:
buildjet-runs-on: buildjet-8vcpu-ubuntu-2204
buildjet-runs-on: buildjet-8vcpu-ubuntu-2204
arch: amd64
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/publish-gstreamer-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
uses: ./.github/workflows/publish-gstreamer-base.yaml
with:
buildjet-runs-on: namespace-profile-arm-16
arch: arm64
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
14 changes: 7 additions & 7 deletions .github/workflows/publish-gstreamer-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
buildjet-runs-on:
required: true
type: string
arch:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
Expand Down Expand Up @@ -39,7 +42,7 @@ jobs:
GSTREAMER_VERSION=${{ env.GST_VERSION }}
LIBNICE_VERSION=${{ env.LIBNICE_VERSION }}
file: ./build/gstreamer/Dockerfile-base
tags: livekit/gstreamer:base-${{ env.GST_VERSION }}
tags: livekit/gstreamer:${{ env.GST_VERSION }}-base-${{ inputs.arch }}

- name: Build and push dev
uses: docker/build-push-action@v5
Expand All @@ -50,7 +53,7 @@ jobs:
GSTREAMER_VERSION=${{ env.GST_VERSION }}
LIBNICE_VERSION=${{ env.LIBNICE_VERSION }}
file: ./build/gstreamer/Dockerfile-dev
tags: livekit/gstreamer:dev-${{ env.GST_VERSION }}
tags: livekit/gstreamer:${{ env.GST_VERSION }}-dev-${{ inputs.arch }}

- name: Build and push prod
uses: docker/build-push-action@v5
Expand All @@ -61,10 +64,7 @@ jobs:
GSTREAMER_VERSION=${{ env.GST_VERSION }}
LIBNICE_VERSION=${{ env.LIBNICE_VERSION }}
file: ./build/gstreamer/Dockerfile-prod
tags: livekit/gstreamer:prod-${{ env.GST_VERSION }}

- name: Prune docker state
run: docker rmi livekit/gstreamer:base-${{ env.GST_VERSION }}
tags: livekit/gstreamer:${{ env.GST_VERSION }}-prod-${{ inputs.arch }}

- name: Build and push prod RS
uses: docker/build-push-action@v5
Expand All @@ -75,4 +75,4 @@ jobs:
GSTREAMER_VERSION=${{ env.GST_VERSION }}
LIBNICE_VERSION=${{ env.LIBNICE_VERSION }}
file: ./build/gstreamer/Dockerfile-prod-rs
tags: livekit/gstreamer:prod-rs-${{ env.GST_VERSION }}
tags: livekit/gstreamer:${{ env.GST_VERSION }}-prod-rs-${{ inputs.arch }}
25 changes: 25 additions & 0 deletions .github/workflows/publish-gstreamer-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: GStreamer publish tag

on:
workflow_dispatch:

jobs:
tag-gstreamer-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run tag script
run: ./build/gstreamer/tag.sh


2 changes: 1 addition & 1 deletion build/gstreamer/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG GSTREAMER_VERSION

FROM livekit/gstreamer:${GSTREAMER_VERSION}-base
FROM livekit/gstreamer:${GSTREAMER_VERSION}-base-${TARGETARCH}

ENV DEBUG=true
ENV OPTIMIZATIONS=false
Expand Down
2 changes: 1 addition & 1 deletion build/gstreamer/Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG GSTREAMER_VERSION

FROM livekit/gstreamer:${GSTREAMER_VERSION}-base
FROM livekit/gstreamer:${GSTREAMER_VERSION}-base-${TARGETARCH}

ENV DEBUG=false
ENV OPTIMIZATIONS=true
Expand Down
6 changes: 3 additions & 3 deletions build/gstreamer/Dockerfile-prod-rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG GSTREAMER_VERSION

FROM livekit/gstreamer:${GSTREAMER_VERSION}-base
FROM livekit/gstreamer:${GSTREAMER_VERSION}-base-${TARGETARCH}

FROM livekit/gstreamer:${GSTREAMER_VERSION}-dev
FROM livekit/gstreamer:${GSTREAMER_VERSION}-dev-${TARGETARCH}

COPY --from=0 /gst-plugins-rs /gst-plugins-rs

Expand All @@ -14,6 +14,6 @@ COPY compile-rs /

RUN /compile-rs

FROM livekit/gstreamer:${GSTREAMER_VERSION}-prod
FROM livekit/gstreamer:${GSTREAMER_VERSION}-prod-${TARGETARCH}

COPY --from=1 /compiled-binaries /
27 changes: 27 additions & 0 deletions build/gstreamer/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

image_suffix=(base dev prod prod-rs)
archs=(amd64 arm64)
gst_version=1.22.8

for suffix in ${image_suffix[*]}
do
digests=()
for arch in ${archs[*]}
do
digest=`docker manifest inspect livekit/gstreamer:$gst_version-$suffix-$arch | jq ".manifests[] | select(.platform.architecture == \"$arch\").digest"`
# remove quotes
digest=${digest:1:$[${#digest}-2]}
digests+=($digest)
done

manifests=""
for digest in ${digests[*]}
do
manifests+=" livekit/gstreamer@$digest"
done

docker manifest create livekit/gstreamer:$gst_version-$suffix$manifests
docker manifest push livekit/gstreamer:$gst_version-$suffix
done

4 changes: 3 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path"
"runtime"
"strings"

"github.com/livekit/mageutil"
Expand Down Expand Up @@ -165,9 +166,10 @@ func buildGstreamer(cmd string) error {
" --build-arg GSTREAMER_VERSION=%s"+
" --build-arg LIBNICE_VERSION=%s"+
" -t livekit/gstreamer:%s-%s"+
" -t livekit/gstreamer:%s-%s-%s"+
" -f build/gstreamer/Dockerfile-%s"+
" ./build/gstreamer",
cmd, gstVersion, libniceVersion, gstVersion, build, build,
cmd, gstVersion, libniceVersion, gstVersion, build, gstVersion, build, runtime.GOARCH, build,
))
}

Expand Down

0 comments on commit e8a71ff

Please sign in to comment.