Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi architecture container image build on ghcr and snapserver update #5

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 66 additions & 40 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,82 @@
name: Docker build and release

on:
release:
types: [published]
push:
branches: [master,develop]
pull_request:

jobs:
deploy_image:
name: 'Publish: DockerHub'
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
build:
name: 'Build container image'
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
outputs:
digest_arm64: ${{ steps.export_digest.outputs.digest_arm64 }}
digest_amd64: ${{ steps.export_digest.outputs.digest_amd64 }}
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ github.repository }}"

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Generating release tags and labels
if: github.event_name == 'release'
id: release_meta
uses: docker/metadata-action@v4
with:
images: jaedb/snapserver
tags: |
latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Generating edge branch labels
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
id: edge_meta
uses: docker/metadata-action@v4
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
images: jaedb/snapserver
tags: ${{ steps.extract_branch.outputs.branch }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true

- name: Login to DockerHub
uses: docker/login-action@v1
- name: Export digest
id: export_digest
run: |
arch="$(echo -n ${{ matrix.platform }} | sed -e 's/linux\///')"
digest="${{ steps.build.outputs.digest }}"
echo "digest_${arch}=${digest#sha256:}" >> "$GITHUB_OUTPUT"

merge:
runs-on: "ubuntu-24.04"
needs:
- build
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
images: ghcr.io/${{ github.repository }}

- name: Build and push
uses: docker/build-push-action@v2
- name: Login to GHCR
uses: docker/login-action@v3
with:
push: true
tags: ${{ steps.release_meta.outputs.tags || steps.edge_meta.outputs.tags }}
labels: ${{ steps.release_meta.outputs.labels || steps.edge_meta.outputs.tags }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Create manifest list and push
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
ghcr.io/${{ github.repository }}@sha256:${{ needs.build.outputs.digest_arm64 }} \
ghcr.io/${{ github.repository }}@sha256:${{ needs.build.outputs.digest_amd64 }}

- name: Inspect image
run: docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.11-alpine
FROM python:3-alpine

ARG LIBRESPOT_VERSION=0.6.0-r0
ARG SNAPCAST_VERSION=0.28.0-r1
ARG SNAPCAST_VERSION=0.29.0-r0

# Add testing libraries: source of the librespot binary
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories
Expand Down