Merge pull request #2072 from charlesomer/development

New docker pipeline.

Many thanks, Charles.
This commit is contained in:
Mike Brady
2025-09-26 16:34:06 +01:00
committed by GitHub
9 changed files with 171 additions and 188 deletions
@@ -1,80 +0,0 @@
# Builds a docker image when a commit is made. Also pushes the build if the branch is 'master' or 'development'.
# Tag pattern
# 'master' - rolling, rolling-classic
# 'development' - development, development-classic
name: docker-build-on-push.yaml
on:
workflow_dispatch:
push:
branches:
- master
- development
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
NQPTP_BRANCH: main
jobs:
build-and-publish:
if: github.event_name != 'pull_request'
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
- name: Set SHAIRPORT_SYNC_BRANCH env.
run: echo "SHAIRPORT_SYNC_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Is branch "master"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }}
run: |
echo "IMAGE_TAG_BASE=rolling" >> $GITHUB_ENV
- name: Is branch "development"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }}
run: |
echo "NQPTP_BRANCH=development" >> $GITHUB_ENV
echo "IMAGE_TAG_BASE=development" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.6.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.11.1
- name: Login to Docker Registry
uses: docker/login-action@v3.5.0
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Build and Push (Classic)
uses: docker/build-push-action@v6.18.0
with:
context: ./
file: ./docker/classic/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ env.IMAGE_TAG_BASE != '' }}
tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}-classic
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
- name: Build and Push (AirPlay 2)
uses: docker/build-push-action@v6.18.0
with:
context: ./
file: ./docker/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ env.IMAGE_TAG_BASE != '' }}
tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
NQPTP_BRANCH=${{ env.NQPTP_BRANCH }}
@@ -0,0 +1,95 @@
# Builds and pushes a docker image in the following scenarios:
# When a commit is made to 'master' or 'development'.
# Tag pattern
# 'master' - rolling, rolling-classic
# 'development' - development, development-classic
# When a tag is created.
# Tag pattern: '[tag]' & '[tag]-classic'
# TODO: Does not currently push 'latest' or 'classic' tags.
# Builds but does not push a docker image for PRs.
name: Build and conditionally push docker image
on:
workflow_dispatch:
push:
branches:
- master
- development
tags:
- "*"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
docker-vars:
uses: ./.github/workflows/docker-vars.yaml
build-docker-image-and-publish:
name: Build and conditionally push docker image
needs:
- docker-vars
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- name: classic
dockerfile: ./docker/classic/Dockerfile
tag_suffix: -classic
build_args: |
SHAIRPORT_SYNC_BRANCH=.
- name: main
dockerfile: ./docker/Dockerfile
tag_suffix: ""
build_args: |
SHAIRPORT_SYNC_BRANCH=.
NQPTP_BRANCH=${{ needs.docker-vars.outputs.nqptp_branch }}
steps:
- name: Login to Docker Registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
if: needs.docker-vars.outputs.push_docker_image == 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.8.0
- name: Checkout shairport sync repo
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Build and push ${{ matrix.name }}
uses: docker/build-push-action@v6.13.0
env:
registry_and_name: ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}
with:
context: ./
file: ${{ matrix.dockerfile }}
platforms: ${{ needs.docker-vars.outputs.docker_platforms }}
push: ${{ needs.docker-vars.outputs.push_docker_image == 'true' }}
# Assign tags based on branch or tag type for clarity
tags: |
${{ github.ref_type == 'branch' && github.ref_name == 'development'
&& format('{0}:development{1}', env.registry_and_name, matrix.tag_suffix) || '' }}
${{ github.ref_type == 'branch' && github.ref_name == 'master'
&& format('{0}:rolling{1}', env.registry_and_name, matrix.tag_suffix) || '' }}
${{ github.ref_type == 'tag'
&& format('{0}:{1}{2}', env.registry_and_name, github.ref_name, matrix.tag_suffix) || '' }}
build-args: |
${{ matrix.build_args }}
# TODO: Fix pushing of 'latest' and 'classic' tags.
# env.is_tag == 'true' && env.branch_name == 'master' && format('{0}:latest{1}', env.registry_and_name, matrix.tag_suffix) || ''
+46
View File
@@ -0,0 +1,46 @@
on:
workflow_call:
outputs:
docker_platforms:
description: "The docker platforms to build for."
value: ${{ jobs.docker-vars.outputs.docker_platforms }}
nqptp_branch:
description: "The NQPTP branch."
value: ${{ jobs.docker-vars.outputs.nqptp_branch }}
push_docker_image:
description: "Whether to push the docker image."
value: ${{ jobs.docker-vars.outputs.push_docker_image }}
jobs:
docker-vars:
name: Set variables required for docker build.
runs-on: ubuntu-22.04
env:
NQPTP_BRANCH: main
PUSH_DOCKER_IMAGE: "false"
outputs:
nqptp_branch: ${{ env.NQPTP_BRANCH }}
push_docker_image: ${{ env.PUSH_DOCKER_IMAGE }}
docker_platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
steps:
- name: Push docker image if this is a tag.
if: github.ref_type == 'tag'
run: |
echo "PUSH_DOCKER_IMAGE=true" >> "$GITHUB_ENV"
- name: Push docker image if this is the "master" or "development" branch.
if: |
github.ref_type == 'branch' &&
(
github.ref_name == 'master' ||
github.ref_name == 'development'
)
run: |
echo "PUSH_DOCKER_IMAGE=true" >> "$GITHUB_ENV"
- name: If 'development' branch, set NQPTP_BRANCH to 'development'.
if: |
github.ref_type == 'branch' &&
github.ref_name == 'development'
run: |
echo "NQPTP_BRANCH=development" >> "$GITHUB_ENV"
-89
View File
@@ -1,89 +0,0 @@
# Builds & pushes a docker image when a tag is created.
# Tag pattern: '[tag]' & '[tag]-classic'
# 'latest' & 'classic' also, when master tagged.
# Only pushes the tag when it matches one of the following patterns:
# X, X.Y or X.Y.Z
name: Build and push Docker images...
on:
workflow_dispatch:
push:
tags:
- '[0-9]+' # X
- '[0-9]+\.[0-9]+' # X.Y
- '[0-9]+\.[0-9]+\.[0-9]+' # X.Y.Z
env:
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
NQPTP_BRANCH: main
LATEST_TAG: false
jobs:
main:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
- name: Set SHAIRPORT_SYNC_BRANCH env.
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "SHAIRPORT_SYNC_BRANCH=${branch}" >> $GITHUB_ENV
- name: Set tag env
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Is branch "development"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }}
run: |
echo "NQPTP_BRANCH=development" >> $GITHUB_ENV
- name: Is branch "danger-2301"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'danger-2301' }}
run: |
echo "NQPTP_BRANCH=development" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.6.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.11.1
- name: Login to Docker Registry
uses: docker/login-action@v3.5.0
with:
# registry: docker.io # default
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Build and push (classic)
uses: docker/build-push-action@v6.18.0
with:
context: ./
file: ./docker/classic/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: |
${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-classic
${{ env.LATEST_TAG == 'true' && format('{0}:classic', secrets.DOCKER_IMAGE_NAME) || '' }}
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
- name: Build and Push AirPlay 2 Version
uses: docker/build-push-action@v6.18.0
with:
context: ./
file: ./docker/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: |
mikebrady/sps-private:${{ env.GIT_TAG }}
mikebrady/sps-private:latest
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
NQPTP_BRANCH=${{ env.NQPTP_BRANCH }}
+5 -4
View File
@@ -9,8 +9,8 @@ RUN apk -U add build-base git nasm pkgconf
RUN mkdir -p /ffmpeg_sources /ffmpeg_build
WORKDIR /ffmpeg_sources
ARG FFMPEG_BRANCH
RUN git clone --depth=1 -b "$FFMPEG_BRANCH" https://git.ffmpeg.org/ffmpeg.git
WORKDIR /ffmpeg_sources/ffmpeg
RUN git clone --depth=1 -b "$FFMPEG_BRANCH" https://github.com/FFmpeg/FFmpeg
WORKDIR /ffmpeg_sources/FFmpeg
RUN ./configure \
--prefix="/ffmpeg_build" \
--extra-libs="-lpthread -lm" \
@@ -146,8 +146,9 @@ RUN apk -U add \
mosquitto \
popt \
soxr \
curl && \
rm -rfv /lib/apk/db/* && \
curl
RUN rm -rfv /lib/apk/db/* && \
rm -rfv /etc/avahi/services/*.service && \
rm -rf /usr/share/man && \
addgroup shairport-sync && \
+2 -2
View File
@@ -10,8 +10,8 @@ RUN apk -U add build-base git nasm pkgconf
RUN mkdir -p /ffmpeg_sources /ffmpeg_build
WORKDIR /ffmpeg_sources
ARG FFMPEG_BRANCH
RUN git clone --depth=1 -b "$FFMPEG_BRANCH" https://git.ffmpeg.org/ffmpeg.git
WORKDIR /ffmpeg_sources/ffmpeg
RUN git clone --depth=1 -b "$FFMPEG_BRANCH" https://github.com/FFmpeg/FFmpeg
WORKDIR /ffmpeg_sources/FFmpeg
RUN ./configure \
--prefix="/ffmpeg_build" \
--extra-libs="-lpthread -lm" \
+11 -6
View File
@@ -3,18 +3,21 @@
# exist if any command returns a non-zero result
set -e
if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ]; then
echo "Shairport Sync Startup ($(date))"
if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 1 ]; then
rm -rf /run/dbus/dbus.pid
rm -rf /run/avahi-daemon/pid
dbus-uuidgen --ensure
dbus-daemon --system
dbus-uuidgen --ensure
dbus-daemon --system
[ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ] || avahi-daemon --daemonize --no-chroot
avahi-daemon --daemonize --no-chroot
fi
while [ ! -f /var/run/avahi-daemon/pid ]; do
echo "Warning: avahi is not running, sleeping for 1 second before trying to start shairport-sync"
sleep 1
echo "Warning: avahi is not running, sleeping for 5 seconds before trying to start shairport-sync"
sleep 5
done
# for PipeWire
@@ -24,4 +27,6 @@ export XDG_RUNTIME_DIR=/tmp
export PULSE_SERVER=unix:/tmp/pulseaudio.socket
export PULSE_COOKIE=/tmp/pulseaudio.cookie
echo "Finished startup tasks ($(date)), starting Shairport Sync."
exec /usr/local/bin/shairport-sync "$@"
+1 -2
View File
@@ -3,10 +3,9 @@
services:
shairport-sync:
image: mikebrady/shairport-sync:latest
network_mode: host
network_mode: host # Required for AirPlay 2
restart: unless-stopped
# environment:
# S6_KEEP_ENV: 1 # Allow S6 to pass environment variables from compose file
# PULSE_SERVER: unix:/tmp/pulseaudio.socket # Path for PulseAudio socket
# PULSE_COOKIE: /tmp/pulseaudio.cookie # Path for PulseAudio cookie
# XDG_RUNTIME_DIR: /tmp # Path for pipewire
+11 -5
View File
@@ -3,21 +3,25 @@
# exist if any command returns a non-zero result
set -e
if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ]; then
echo "Shairport Sync Startup ($(date))"
if [ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 1 ]; then
rm -rf /run/dbus/dbus.pid
rm -rf /run/avahi-daemon/pid
dbus-uuidgen --ensure
dbus-daemon --system
avahi-daemon --daemonize --no-chroot
fi
echo "Starting NQPTP ($(date))"
(/usr/local/bin/nqptp > /dev/null 2>&1) &
[ -z ${ENABLE_AVAHI+x} ] || [ $ENABLE_AVAHI -eq 0 ] || avahi-daemon --daemonize --no-chroot
while [ ! -f /var/run/avahi-daemon/pid ]; do
echo "Warning: avahi is not running, sleeping for 1 second before trying to start shairport-sync"
sleep 1
echo "Warning: avahi is not running, sleeping for 5 seconds before trying to start shairport-sync"
sleep 5
done
# for PipeWire
@@ -27,4 +31,6 @@ export XDG_RUNTIME_DIR=/tmp
export PULSE_SERVER=unix:/tmp/pulseaudio.socket
export PULSE_COOKIE=/tmp/pulseaudio.cookie
echo "Finished startup tasks ($(date)), starting Shairport Sync."
exec /usr/local/bin/shairport-sync "$@"