]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Extra command-line arguments passed when the Docker image is launched are passed...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Sun, 23 Oct 2022 15:00:41 +0000 (16:00 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Sun, 23 Oct 2022 15:00:41 +0000 (16:00 +0100)
The shairport-sync instance runs as user and group shairport-sync which has reduced privileges.

The "classic" docker image now uses the s6-overlay to manage processes.

17 files changed:
docker/Dockerfile
docker/README.md
docker/classic/Dockerfile
docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/finish [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/run [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/type [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/finish [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/run [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/type [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/startup/script.sh [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/startup/type [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/startup/up [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/01-dbus [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/02-avahi [new file with mode: 0644]
docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/startup [new file with mode: 0644]
docker/docker-compose.yaml
docker/etc/s6-overlay/s6-rc.d/03-nqptp/run

index a34d2c503f3d88e446b930f5b00730d60f788165..11647acd0ac2f9fd13c1e3124ecdb43c3dd98cc2 100644 (file)
@@ -16,21 +16,18 @@ RUN apk -U add \
         dbus \
         alsa-lib-dev \
         popt-dev \
-        mbedtls-dev \
         soxr-dev \
         avahi-dev \
         libconfig-dev \
         libsndfile-dev \
         mosquitto-dev \
-        xmltoman \
-        openssh-client \
         libsodium-dev \
+        libgcrypt-dev \
         ffmpeg-dev \
         xxd \
         libressl-dev \
         openssl-dev \
-        libplist-dev \
-        libgcrypt-dev
+        libplist-dev
 
 ##### ALAC #####
 RUN git clone https://github.com/mikebrady/alac
@@ -76,7 +73,6 @@ RUN apk -U add \
         dbus \
         popt \
         glib \
-        mbedtls \
         soxr \
         avahi \
         avahi-tools \
@@ -86,8 +82,8 @@ RUN apk -U add \
         libuuid \
         ffmpeg \
         libsodium \
-        libplist \
-        libgcrypt
+        libgcrypt \
+        libplist
 
 # Copy build files.
 COPY --from=builder /shairport-sync/build/install/usr/local/bin/shairport-sync /usr/local/bin/shairport-sync
@@ -111,6 +107,4 @@ RUN addgroup -g 29 docker_audio && addgroup shairport-sync docker_audio && addgr
 # Remove anything we don't need.
 RUN rm -rf /lib/apk/db/*
 
-ENTRYPOINT [ "/init" ]
-
-CMD [ "/usr/local/bin/shairport-sync",  "-v",  "--statistics" ]
\ No newline at end of file
+ENTRYPOINT [ "/init", "s6-setuidgid", "shairport-sync", "/usr/local/bin/shairport-sync" ]
index 2b27e77f9f2d03f75eab583f19508adc27d82d91..8c31a84d0fde92aa9dd0fb238c34d6868131189e 100644 (file)
@@ -2,43 +2,32 @@
 
 Available at: https://hub.docker.com/r/mikebrady/shairport-sync
 
-The following docker tags are available:
+Please note if you want the development version of the image including Airplay 2 support, please pull the image with the `development` tag using the following command:
 ```
-[tag]
-[tag]-classic
-
-(build from newest tag)
-stable
-stable-classic
-
-(latest build from master)
-latest
-latest-classic
-
-(latest build from development)
-development
-development-classic
+docker pull mikebrady/shairport-sync:development
 ```
 
+When using the below commands, you should replace `mikebrady/shairport-sync` with `mikbrady/shairport-sync:development`.
+
 ## Example Docker Compose File
 See the `docker-compose.yaml` file in this folder for an example.
 
-## Example Docker Run
+## Docker Run
 
 ```
 $ docker run -d --restart unless-stopped --net host --device /dev/snd \
-    mikebrady/shairport-sync:<tag>
+    mikebrady/shairport-sync
 ```
 
 ### Options
 
-You can change the default commands passed to Shairport Sync. Here is an example:
+Command line options will be passed to Shairport Sync. Here is an example:
 ```
 $ docker run -d --restart unless-stopped --net host --device /dev/snd \
-    mikebrady/shairport-sync:<tag> shairport-sync -v \
-    --statistics -a DenSystem -d hw:0 -c PCM
+    mikebrady/shairport-sync:development \
+    -v --statistics -a DenSystem -d hw:0 -c PCM
 ```
-This will sent audio to alsa hardware device `hw:0` and make use of the that device's mixer control called `PCM`. The service will be visible as `DenSystem` on the network.
+This will send audio to alsa hardware device `hw:0` and make use of the that device's mixer control called `PCM`. The service will be visible as `DenSystem` on the network.
 
 ## Configuration File
 
@@ -54,9 +43,9 @@ docker buildx build --platform linux/arm/v7 -f ./docker/Dockerfile --build-arg S
 `SHAIRPORT_SYNC_BRANCH` and `NQPTP_BRANCH` are required to ensure the image is built using the expected branch.
 `--no-cache` needs to be used to force buildx to pull the NQPTP branch for new updates. This slows down the build time though so can be removed when it is not beneficial during testing.
 
-### AirPlay 1 Only
+### "Classic" AirPlay
 
-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.
+The "Classic" AirPlay only dockerfile is in the `classic` folder. This also includes the `start.sh` script used by the container.
 
 ### GitHub Action Builds
 
@@ -64,4 +53,4 @@ Requires the following secrets to be set in the repo:
 - `DOCKER_REGISTRY` - docker.io if using Docker Hub, else set to your registry URL.
 - `DOCKER_REGISTRY_TOKEN` - Access token for your registry.
 - `DOCKER_REGISTRY_USER` - Login user for your registry.
-- `DOCKER_IMAGE_NAME` - The name of the image, for example `your-registry.com/shairport-sync` or just `your-username/shairport-sync` if using Docker Hub.
\ No newline at end of file
+- `DOCKER_IMAGE_NAME` - The name of the image, for example `your-registry.com/shairport-sync` or just `your-username/shairport-sync` if using Docker Hub.
index 0556cd94f55e4604cb07dcbe1a4d552df2861831..3010ca1129b36cf76fbf5619a55bfe84c5e0242a 100644 (file)
@@ -1,5 +1,12 @@
-FROM alpine AS builder-base
-# General Build System:
+FROM alpine:3.12 AS builder
+
+# Classic (aka AirPlay 1) Build
+
+# Check required arguments exist. These will be provided by the Github Action
+# Workflow and are required to ensure the correct branches are being used.
+ARG SHAIRPORT_SYNC_BRANCH
+RUN test -n "$SHAIRPORT_SYNC_BRANCH"
+
 RUN apk -U add \
         git \
         build-base \
@@ -7,63 +14,42 @@ RUN apk -U add \
         automake \
         libtool \
         dbus \
-        su-exec \
         alsa-lib-dev \
-        libdaemon-dev \
         popt-dev \
         mbedtls-dev \
         soxr-dev \
         avahi-dev \
         libconfig-dev \
-        libsndfile-dev \
         mosquitto-dev \
-        xmltoman
-
-# ALAC Build System:
-FROM builder-base AS builder-alac
+        libsndfile-dev
 
+##### ALAC #####
 RUN git clone https://github.com/mikebrady/alac
-WORKDIR alac
-RUN autoreconf -fi
+WORKDIR /alac
+RUN autoreconf -i
 RUN ./configure
 RUN make
 RUN make install
+WORKDIR /
+##### ALAC END #####
 
-# Shairport Sync Build System:
-FROM builder-base AS builder-sps
-
-# This will be modified by the Github Action Workflow and is required
-# to ensure the correct branch is being used.
-ARG SHAIRPORT_SYNC_BRANCH
-RUN test -n "$SHAIRPORT_SYNC_BRANCH"
-
-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
-
+##### SPS #####
 WORKDIR /shairport-sync
 COPY . .
 RUN git checkout "$SHAIRPORT_SYNC_BRANCH"
-RUN autoreconf -fi
-RUN ./configure \
-        --with-alsa \
-        --with-dummy \
-        --with-pipe \
-        --with-stdout \
-        --with-avahi \
-        --with-ssl=mbedtls \
-        --with-soxr \
-        --sysconfdir=/etc \
-        --with-dbus-interface \
-        --with-mpris-interface \
-        --with-mqtt-client \
-        --with-apple-alac \
-        --with-convolution
+WORKDIR /shairport-sync/build
+RUN autoreconf -i ../
+RUN ../configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=mbedtls \
+        --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 $(nproc)
-RUN make install
+RUN DESTDIR=install make install
+WORKDIR /
+##### SPS END #####
 
-# Shairport Sync Runtime System:
-FROM alpine
+# Shairport Sync Runtime System
+FROM crazymax/alpine-s6:3.12-3.1.1.2
 
 RUN apk -U add \
         alsa-lib \
@@ -75,30 +61,29 @@ RUN apk -U add \
         avahi \
         avahi-tools \
         libconfig \
-        libsndfile \
-        mosquitto-libs \
-        su-exec \
-        libgcc \
-        libgc++
+        mosquitto \
+        libsndfile-dev
 
-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/
-COPY --from=builder-sps /etc/dbus-1/system.d/shairport-sync-dbus.conf /etc/dbus-1/system.d/
-COPY --from=builder-sps /etc/dbus-1/system.d/shairport-sync-mpris.conf /etc/dbus-1/system.d/
-COPY --from=builder-sps /usr/local/bin/shairport-sync /usr/local/bin/shairport-sync
+# Copy build files.
+COPY --from=builder /shairport-sync/build/install/usr/local/bin/shairport-sync /usr/local/bin/shairport-sync
+COPY --from=builder /usr/local/lib/libalac.* /usr/local/lib/
+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/classic/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
 
-RUN addgroup shairport-sync 
+RUN addgroup shairport-sync
 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
+RUN addgroup -g 29 docker_audio && addgroup shairport-sync docker_audio && addgroup shairport-sync audio
 
-COPY ./docker/classic/start.sh /
-RUN chmod +x /start.sh
+# Remove anything we don't need.
+RUN rm -rf /lib/apk/db/*
 
-ENTRYPOINT [ "/start.sh" ]
+ENTRYPOINT [ "/init", "s6-setuidgid", "shairport-sync", "/usr/local/bin/shairport-sync" ]
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/finish b/docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/finish
new file mode 100644 (file)
index 0000000..a8222fb
--- /dev/null
@@ -0,0 +1,2 @@
+#!/command/execlineb -S0
+/run/s6/basedir/bin/halt
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/run b/docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/run
new file mode 100644 (file)
index 0000000..8757e5d
--- /dev/null
@@ -0,0 +1,4 @@
+#!/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/classic/etc/s6-overlay/s6-rc.d/01-dbus/type b/docker/classic/etc/s6-overlay/s6-rc.d/01-dbus/type
new file mode 100644 (file)
index 0000000..1780f9f
--- /dev/null
@@ -0,0 +1 @@
+longrun
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/finish b/docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/finish
new file mode 100644 (file)
index 0000000..a8222fb
--- /dev/null
@@ -0,0 +1,2 @@
+#!/command/execlineb -S0
+/run/s6/basedir/bin/halt
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/run b/docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/run
new file mode 100644 (file)
index 0000000..fc50929
--- /dev/null
@@ -0,0 +1,8 @@
+#!/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/classic/etc/s6-overlay/s6-rc.d/02-avahi/type b/docker/classic/etc/s6-overlay/s6-rc.d/02-avahi/type
new file mode 100644 (file)
index 0000000..1780f9f
--- /dev/null
@@ -0,0 +1 @@
+longrun
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/startup/script.sh b/docker/classic/etc/s6-overlay/s6-rc.d/startup/script.sh
new file mode 100644 (file)
index 0000000..c975a40
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "STARTING - $(date)"
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/startup/type b/docker/classic/etc/s6-overlay/s6-rc.d/startup/type
new file mode 100644 (file)
index 0000000..3d92b15
--- /dev/null
@@ -0,0 +1 @@
+oneshot
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/startup/up b/docker/classic/etc/s6-overlay/s6-rc.d/startup/up
new file mode 100644 (file)
index 0000000..0c609ec
--- /dev/null
@@ -0,0 +1 @@
+/etc/s6-overlay/s6-rc.d/startup/script.sh
\ No newline at end of file
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/01-dbus b/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/01-dbus
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/02-avahi b/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/02-avahi
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/startup b/docker/classic/etc/s6-overlay/s6-rc.d/user/contents.d/startup
new file mode 100644 (file)
index 0000000..e69de29
index 6b2394a1b882842193ef5003e8d74b48fc2127e6..1bd66168b3f3c3eb630e2f4e070d482e89e2b6d0 100644 (file)
@@ -2,7 +2,7 @@
 
 services:
   shairport-sync:
-    image: mikebrady/shairport-sync:<tag>
+    image: mikebrady/shairport-sync:development
     network_mode: host
     restart: unless-stopped
     devices:
index 7af2c60171aa15116ece171e2454e66227e39e41..e8b59b2e7afd2fd8a09a930f66d810c5f3123645 100644 (file)
@@ -1,3 +1,3 @@
 #!/command/with-contenv sh
 echo "Starting nqptp"
-exec /usr/local/bin/nqptp -v
\ No newline at end of file
+exec /usr/local/bin/nqptp
\ No newline at end of file