From e887ccd8de4a58079fe8f3fb7e5271a20de281a2 Mon Sep 17 00:00:00 2001 From: Charles <32498151+charlesomer@users.noreply.github.com> Date: Sat, 20 Aug 2022 00:02:54 +0100 Subject: [PATCH] s6 improvements and docker build changes --- .dockerignore | 4 +- .github/ISSUE_TEMPLATE/Bug Report.yaml | 37 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 8 ++++ .github/workflows/docker-build-on-push.yaml | 16 ++++++-- .github/workflows/docker-build-on-tag.yaml | 8 ++-- .gitignore | 2 +- README.md | 2 +- docker/Dockerfile | 24 ++++++------ docker/README.md | 2 +- docker/{airplay1 => classic}/Dockerfile | 6 +-- docker/{airplay1 => classic}/README.md | 2 +- docker/{airplay1 => classic}/start.sh | 0 docker/etc/s6-overlay/s6-rc.d/01-dbus/finish | 2 + docker/etc/s6-overlay/s6-rc.d/01-dbus/run | 3 +- docker/etc/s6-overlay/s6-rc.d/02-avahi/finish | 2 + docker/etc/s6-overlay/s6-rc.d/02-avahi/run | 17 ++++----- docker/etc/s6-overlay/s6-rc.d/03-nqptp/finish | 2 + docker/etc/s6-overlay/s6-rc.d/03-nqptp/run | 3 +- .../etc/s6-overlay/s6-rc.d/startup/script.sh | 2 + docker/etc/s6-overlay/s6-rc.d/startup/type | 1 + docker/etc/s6-overlay/s6-rc.d/startup/up | 1 + .../s6-rc.d/user/contents.d/startup | 0 22 files changed, 106 insertions(+), 38 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/Bug Report.yaml create mode 100644 .github/ISSUE_TEMPLATE/config.yml rename docker/{airplay1 => classic}/Dockerfile (97%) rename docker/{airplay1 => classic}/README.md (73%) rename docker/{airplay1 => classic}/start.sh (100%) create mode 100644 docker/etc/s6-overlay/s6-rc.d/01-dbus/finish create mode 100644 docker/etc/s6-overlay/s6-rc.d/02-avahi/finish create mode 100644 docker/etc/s6-overlay/s6-rc.d/03-nqptp/finish create mode 100644 docker/etc/s6-overlay/s6-rc.d/startup/script.sh create mode 100644 docker/etc/s6-overlay/s6-rc.d/startup/type create mode 100644 docker/etc/s6-overlay/s6-rc.d/startup/up create mode 100644 docker/etc/s6-overlay/s6-rc.d/user/contents.d/startup diff --git a/.dockerignore b/.dockerignore index 98c4e3ee..f5e8e83a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ .github -documents \ No newline at end of file +documents +docker/Dockerfile +docker/classic/Dockerfile \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/Bug Report.yaml b/.github/ISSUE_TEMPLATE/Bug Report.yaml new file mode 100644 index 00000000..11e2f3a1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug Report.yaml @@ -0,0 +1,37 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also, what did you expect to happen? + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + - type: textarea + id: version + attributes: + label: Version? + description: What version of Shairport Sync are you running? (`shairport-sync -V`) + validations: + required: true + - type: checkboxes + id: checked-current-issues + attributes: + label: Check previous issues + description: Please check previous issues (including closed ones) for duplicates. + options: + - label: Confirm + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..08744522 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Questions? + url: https://github.com/mikebrady/shairport-sync/discussions/categories/q-a + about: Please ask and answer questions here. + - name: Feature Requests + url: https://github.com/mikebrady/shairport-sync/discussions/categories/ideas + about: Please submit feature requests/enhancements here. \ No newline at end of file diff --git a/.github/workflows/docker-build-on-push.yaml b/.github/workflows/docker-build-on-push.yaml index 072e9218..dca048e2 100644 --- a/.github/workflows/docker-build-on-push.yaml +++ b/.github/workflows/docker-build-on-push.yaml @@ -1,5 +1,5 @@ # Builds & pushes a docker image when a commit is made to one of the branches specified below. -# Tag pattern: 'unstable-[BRANCH NAME]' & 'unstable-[BRANCH NAME]-airplay1' +# Tag pattern: 'unstable-[BRANCH NAME]' & 'unstable-[BRANCH NAME]-classic' name: Build and push docker image based on commit to specified branches. @@ -43,6 +43,14 @@ jobs: username: ${{ secrets.DOCKER_REGISTRY_USER }} password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + - name: Set tag start (part 1). + if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }} + run: echo "IMAGE_TAG_BASE=unstable" >> $GITHUB_ENV + + - name: Set tag start (part 2). + if: ${{ env.SHAIRPORT_SYNC_BRANCH != 'master' }} + run: echo "IMAGE_TAG_BASE=unstable-${{ env.SHAIRPORT_SYNC_BRANCH }}" >> $GITHUB_ENV + - name: Build and push uses: docker/build-push-action@v2 with: @@ -50,7 +58,7 @@ jobs: file: ./docker/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: true - tags: ${{ secrets.DOCKER_IMAGE_NAME }}:unstable-${{ env.SHAIRPORT_SYNC_BRANCH }} + tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }} build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} NQPTP_BRANCH=${{ env.NQPTP_BRANCH }} @@ -59,9 +67,9 @@ jobs: uses: docker/build-push-action@v2 with: context: ./ - file: ./docker/airplay1/Dockerfile + file: ./docker/classic/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: true - tags: ${{ secrets.DOCKER_IMAGE_NAME }}:unstable-${{ env.SHAIRPORT_SYNC_BRANCH }}-airplay1 + tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}-classic build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} \ No newline at end of file diff --git a/.github/workflows/docker-build-on-tag.yaml b/.github/workflows/docker-build-on-tag.yaml index d345bd89..6762a9bd 100644 --- a/.github/workflows/docker-build-on-tag.yaml +++ b/.github/workflows/docker-build-on-tag.yaml @@ -2,7 +2,7 @@ # It seems this yaml has to exist on the branch the tag refers to. # The following docker tags are created & pushed: -# [RELEASE TAG], [RELEASE TAG]-airplay1, +# [RELEASE TAG], [RELEASE TAG]-classic, name: Build and push docker images on releases. @@ -65,13 +65,13 @@ jobs: SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} NQPTP_BRANCH=${{ env.NQPTP_BRANCH }} - - name: Build and push (AirPlay 1) + - name: Build and push (Classic) uses: docker/build-push-action@v2 with: context: ./ - file: ./docker/airplay1/Dockerfile + file: ./docker/classic/Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: true - tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-airplay1 + tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-classic build-args: | SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 52c49f30..096527a9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ Makefile.in aclocal.m4 autom4te.cache compile -config.* +/config.* configure depcomp install-sh diff --git a/README.md b/README.md index 01e05666..704c8f3e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Shairport Sync does not support AirPlay video or photo streaming. # Quick Start * A building guide is available [here](BUILD.md). -* A Docker image is available on the [Docker Hub](https://hub.docker.com/repository/docker/mikebrady/shairport-sync). +* A Docker image is available on the [Docker Hub](https://hub.docker.com/r/mikebrady/shairport-sync). * Next Steps and Advanced Topics are [here](ADVANCED%20TOPICS/README.md). * Runtime settings are documented [here](scripts/shairport-sync.conf). * Build configuration options are detailed in [CONFIGURATION FLAGS.md](CONFIGURATION%20FLAGS.md). diff --git a/docker/Dockerfile b/docker/Dockerfile index 2a465a38..cb2df177 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -35,7 +35,7 @@ RUN apk -U add \ ##### ALAC ##### RUN git clone https://github.com/mikebrady/alac WORKDIR /alac -RUN autoreconf -fi +RUN autoreconf -i RUN ./configure RUN make RUN make install @@ -46,7 +46,7 @@ WORKDIR / RUN git clone https://github.com/mikebrady/nqptp WORKDIR /nqptp RUN git checkout "$NQPTP_BRANCH" -RUN autoreconf -fi +RUN autoreconf -i RUN ./configure RUN make RUN make install @@ -57,18 +57,19 @@ WORKDIR / WORKDIR /shairport-sync COPY . . RUN git checkout "$SHAIRPORT_SYNC_BRANCH" -RUN autoreconf -fi -RUN ./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-airplay-2 \ +WORKDIR /shairport-sync/build +RUN autoreconf -i ../ +RUN ../configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-airplay-2 \ --with-metadata --with-dummy --with-pipe --with-dbus-interface \ --with-stdout --with-mpris-interface --with-mqtt-client \ --with-apple-alac --with-convolution -RUN make -j -RUN make install +RUN make -j $(nproc) +RUN DESTDIR=install make install WORKDIR / ##### SPS END ##### # Shairport Sync Runtime System -FROM crazymax/alpine-s6:3.12-3.0.0.2 +FROM crazymax/alpine-s6:3.12-3.1.1.2 RUN apk -U add \ alsa-lib \ @@ -88,13 +89,14 @@ RUN apk -U add \ libgcrypt # Copy build files. -COPY --from=builder /usr/local/bin/shairport-sync /usr/local/bin/shairport-sync +COPY --from=builder /shairport-sync/build/install/usr/local/bin/shairport-sync /usr/local/bin/shairport-sync COPY --from=builder /usr/local/bin/nqptp /usr/local/bin/nqptp COPY --from=builder /usr/local/lib/libalac.* /usr/local/lib/ -COPY --from=builder /etc/dbus-1/system.d/shairport-sync-dbus.conf /etc/dbus-1/system.d/ -COPY --from=builder /etc/dbus-1/system.d/shairport-sync-mpris.conf /etc/dbus-1/system.d/ +COPY --from=builder /shairport-sync/build/install/etc/dbus-1/system.d/shairport-sync-dbus.conf /etc/dbus-1/system.d/ +COPY --from=builder /shairport-sync/build/install/etc/dbus-1/system.d/shairport-sync-mpris.conf /etc/dbus-1/system.d/ COPY ./docker/etc/s6-overlay/s6-rc.d /etc/s6-overlay/s6-rc.d +RUN chmod +x /etc/s6-overlay/s6-rc.d/startup/script.sh # Create non-root user for running the container -- running as the user 'shairport-sync' also allows # Shairport Sync to provide the D-Bus and MPRIS interfaces within the container @@ -110,4 +112,4 @@ RUN rm -rf /lib/apk/db/* ENTRYPOINT [ "/init" ] -CMD /usr/local/bin/shairport-sync -vu --statistics \ No newline at end of file +CMD [ "/usr/local/bin/shairport-sync", "-v", "--statistics" ] \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index 408215fe..12b8f3bb 100644 --- a/docker/README.md +++ b/docker/README.md @@ -44,7 +44,7 @@ docker buildx build --platform linux/arm/v7 -f ./docker/Dockerfile --build-arg S ### AirPlay 1 Only -The AirPlay1 only dockerfile is in the `airplay1` folder. This also includes the `start.sh` script used by the container. Please note that the AirPlay 1 image built via the AirPlay 2 branch has missing functionality, e.g. it does not work with multiple instances on the same hardware; does not support iTunes for Windows etc. +The AirPlay 1 only dockerfile is in the `classic` folder. This also includes the `start.sh` script used by the container. Please note that the AirPlay 1 image built via the AirPlay 2 branch has missing functionality, e.g. it does not work with multiple instances on the same hardware; does not support iTunes for Windows etc. ### GitHub Action Builds diff --git a/docker/airplay1/Dockerfile b/docker/classic/Dockerfile similarity index 97% rename from docker/airplay1/Dockerfile rename to docker/classic/Dockerfile index 6276f08d..a2c33af5 100644 --- a/docker/airplay1/Dockerfile +++ b/docker/classic/Dockerfile @@ -41,7 +41,7 @@ COPY --from=builder-alac /usr/local/lib/libalac.* /usr/local/lib/ COPY --from=builder-alac /usr/local/lib/pkgconfig/alac.pc /usr/local/lib/pkgconfig/alac.pc COPY --from=builder-alac /usr/local/include /usr/local/include -WORKDIR shairport-sync +WORKDIR /shairport-sync COPY . . RUN git checkout "$SHAIRPORT_SYNC_BRANCH" RUN autoreconf -fi @@ -80,7 +80,7 @@ RUN apk -U add \ libgcc \ libgc++ -RUN rm -rf /lib/apk/db/* +RUN rm -rf /lib/apk/db/* COPY --from=builder-alac /usr/local/lib/libalac.* /usr/local/lib/ COPY --from=builder-sps /etc/shairport-sync* /etc/ @@ -97,7 +97,7 @@ RUN adduser -D shairport-sync -G shairport-sync # Add the shairport-sync user to the pre-existing audio group, which has ID 29, for access to the ALSA stuff RUN addgroup -g 29 docker_audio && addgroup shairport-sync docker_audio -COPY ./docker/airplay1/start.sh / +COPY ./docker/classic/start.sh / RUN chmod +x /start.sh ENTRYPOINT [ "/start.sh" ] diff --git a/docker/airplay1/README.md b/docker/classic/README.md similarity index 73% rename from docker/airplay1/README.md rename to docker/classic/README.md index f8335d76..4dd3bf76 100644 --- a/docker/airplay1/README.md +++ b/docker/classic/README.md @@ -1,3 +1,3 @@ -# AirPlay 1 Only Docker Image +# Classic (AirPlay 1 Only) Docker Image See the [Shairport Sync Docker Hub Repo](https://hub.docker.com/r/mikebrady/shairport-sync) for available tags. diff --git a/docker/airplay1/start.sh b/docker/classic/start.sh similarity index 100% rename from docker/airplay1/start.sh rename to docker/classic/start.sh diff --git a/docker/etc/s6-overlay/s6-rc.d/01-dbus/finish b/docker/etc/s6-overlay/s6-rc.d/01-dbus/finish new file mode 100644 index 00000000..a8222fb0 --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/01-dbus/finish @@ -0,0 +1,2 @@ +#!/command/execlineb -S0 +/run/s6/basedir/bin/halt \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/01-dbus/run b/docker/etc/s6-overlay/s6-rc.d/01-dbus/run index 096e093a..8757e5d5 100644 --- a/docker/etc/s6-overlay/s6-rc.d/01-dbus/run +++ b/docker/etc/s6-overlay/s6-rc.d/01-dbus/run @@ -1,3 +1,4 @@ -#!/bin/sh +#!/command/with-contenv sh rm -rf /var/run/dbus.pid +echo "Starting dbus" exec dbus-daemon --system --nofork \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/02-avahi/finish b/docker/etc/s6-overlay/s6-rc.d/02-avahi/finish new file mode 100644 index 00000000..a8222fb0 --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/02-avahi/finish @@ -0,0 +1,2 @@ +#!/command/execlineb -S0 +/run/s6/basedir/bin/halt \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/02-avahi/run b/docker/etc/s6-overlay/s6-rc.d/02-avahi/run index e1cdd1c8..fc509297 100644 --- a/docker/etc/s6-overlay/s6-rc.d/02-avahi/run +++ b/docker/etc/s6-overlay/s6-rc.d/02-avahi/run @@ -1,9 +1,8 @@ -#!/bin/sh -avahi-daemon --check -if [ $? -eq 0 ]; then - echo "Reloading avahi-daemon." - exec avahi-daemon --no-chroot --reload -else - echo "Starting avahi-daemon." - exec avahi-daemon --no-chroot -fi \ No newline at end of file +#!/command/with-contenv sh +sleep 5 +while [ ! -f /var/run/dbus.pid ]; do + "dbus is not running, sleeping for 5 seconds before trying to start avahi" + sleep 5 +done +echo "Starting avahi" +exec avahi-daemon --no-chroot \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/03-nqptp/finish b/docker/etc/s6-overlay/s6-rc.d/03-nqptp/finish new file mode 100644 index 00000000..a8222fb0 --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/03-nqptp/finish @@ -0,0 +1,2 @@ +#!/command/execlineb -S0 +/run/s6/basedir/bin/halt \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/03-nqptp/run b/docker/etc/s6-overlay/s6-rc.d/03-nqptp/run index 8b07c68f..7af2c601 100644 --- a/docker/etc/s6-overlay/s6-rc.d/03-nqptp/run +++ b/docker/etc/s6-overlay/s6-rc.d/03-nqptp/run @@ -1,2 +1,3 @@ -#!/bin/sh +#!/command/with-contenv sh +echo "Starting nqptp" exec /usr/local/bin/nqptp -v \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/startup/script.sh b/docker/etc/s6-overlay/s6-rc.d/startup/script.sh new file mode 100644 index 00000000..c975a403 --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/startup/script.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "STARTING - $(date)" \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/startup/type b/docker/etc/s6-overlay/s6-rc.d/startup/type new file mode 100644 index 00000000..3d92b15f --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/startup/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/startup/up b/docker/etc/s6-overlay/s6-rc.d/startup/up new file mode 100644 index 00000000..0c609ec6 --- /dev/null +++ b/docker/etc/s6-overlay/s6-rc.d/startup/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/startup/script.sh \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/user/contents.d/startup b/docker/etc/s6-overlay/s6-rc.d/user/contents.d/startup new file mode 100644 index 00000000..e69de29b -- 2.47.2