From: Charles Date: Mon, 22 Sep 2025 21:37:57 +0000 (+0100) Subject: New docker pipeline. X-Git-Tag: 5.0-post-dev~78^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8e61481399b3b3cb03dbac80d3bd5ce290a5db8;p=thirdparty%2Fshairport-sync.git New docker pipeline. --- diff --git a/.github/workflows/docker-build-on-push.yaml b/.github/workflows/docker-build-on-push.yaml deleted file mode 100644 index 95132f87..00000000 --- a/.github/workflows/docker-build-on-push.yaml +++ /dev/null @@ -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 }} diff --git a/.github/workflows/docker-on-push-tag-or-pr.yaml b/.github/workflows/docker-on-push-tag-or-pr.yaml new file mode 100644 index 00000000..306a413e --- /dev/null +++ b/.github/workflows/docker-on-push-tag-or-pr.yaml @@ -0,0 +1,87 @@ +# 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' +# 'latest' & 'classic' also, when master tagged. + +# 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=${{ needs.docker-vars.outputs.shairport_sync_branch }} + - name: main + dockerfile: ./docker/Dockerfile + tag_suffix: "" + build_args: | + SHAIRPORT_SYNC_BRANCH=${{ needs.docker-vars.outputs.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 }} + + - 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 }} + is_tag: ${{ github.ref_type == 'tag' }} + branch_name: ${{ needs.docker-vars.outputs.shairport_sync_branch }} + with: + context: ./ + file: ${{ matrix.dockerfile }} + platforms: ${{ needs.docker-vars.outputs.docker_platforms }} + push: ${{ needs.docker-vars.outputs.push_docker_image == 'true' }} + tags: | + ${{ env.branch_name == 'development' && format('{0}:development{1}', env.registry_and_name, matrix.tag_suffix) || '' }} + ${{ env.branch_name == 'master' && format('{0}:rolling{1}', env.registry_and_name, matrix.tag_suffix) || '' }} + ${{ env.is_tag == 'true' && format('{0}:{1}{2}', env.registry_and_name, github.ref_name, matrix.tag_suffix) || '' }} + ${{ env.is_tag == 'true' && env.branch_name == 'master' && format('{0}:latest{1}', env.registry_and_name, matrix.tag_suffix) || '' }} + build-args: | + ${{ matrix.build_args }} \ No newline at end of file diff --git a/.github/workflows/docker-vars.yaml b/.github/workflows/docker-vars.yaml new file mode 100644 index 00000000..20888b46 --- /dev/null +++ b/.github/workflows/docker-vars.yaml @@ -0,0 +1,54 @@ +on: + workflow_call: + outputs: + shairport_sync_branch: + description: "The SPS branch." + value: ${{ jobs.docker-vars.outputs.shairport_sync_branch }} + 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: + SHAIRPORT_SYNC_BRANCH: "" + NQPTP_BRANCH: main + PUSH_DOCKER_IMAGE: "false" + outputs: + shairport_sync_branch: ${{ env.SHAIRPORT_SYNC_BRANCH }} + 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: Set shairport_sync_branch to branch name. + id: set-branch + run: | + echo "SHAIRPORT_SYNC_BRANCH=${GITHUB_REF##*/}" >> "$GITHUB_ENV" + + - 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' && + ( + env.SHAIRPORT_SYNC_BRANCH == 'master' || + env.SHAIRPORT_SYNC_BRANCH == 'development' + ) + run: | + echo "PUSH_DOCKER_IMAGE=true" >> "$GITHUB_ENV" + + - name: If 'development' branch, set NQPTP_BRANCH to 'development'. + if: env.SHAIRPORT_SYNC_BRANCH == 'development' + run: | + echo "NQPTP_BRANCH=development" >> "$GITHUB_ENV" diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 8b16ba0b..00000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -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 }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 9b1347eb..1cda43e3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 && \ diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 24d2f707..398b2d2b 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -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