diff --git a/README.md b/README.md index 9a65b3ec..37992583 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/r/mikebrady/shairport-sync). +* A Docker image is available on the [Docker Hub](https://hub.docker.com/r/mikebrady/shairport-sync). Also see [docker/README.md](docker/README.md). * 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 dd21bb8b..3ce13cb0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,25 +8,26 @@ ARG NQPTP_BRANCH RUN test -n "$NQPTP_BRANCH" RUN apk -U add \ - git \ - build-base \ + alsa-lib-dev \ autoconf \ automake \ - libtool \ - dbus \ - alsa-lib-dev \ - popt-dev \ - soxr-dev \ avahi-dev \ - libconfig-dev \ - libsndfile-dev \ - mosquitto-dev \ - libsodium-dev \ - libgcrypt-dev \ + build-base \ + dbus \ ffmpeg-dev \ - xxd \ + git \ + libconfig-dev \ + libgcrypt-dev \ + libplist-dev \ libressl-dev \ - libplist-dev + libsndfile-dev \ + libsodium-dev \ + libtool \ + mosquitto-dev \ + popt-dev \ + pulseaudio-dev \ + soxr-dev \ + xxd ##### ALAC ##### RUN git clone https://github.com/mikebrady/alac @@ -55,8 +56,8 @@ COPY . . RUN git checkout "$SHAIRPORT_SYNC_BRANCH" 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 \ +RUN ../configure --sysconfdir=/etc --with-alsa --with-pa --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 $(nproc) @@ -69,25 +70,26 @@ FROM crazymax/alpine-s6:3.17-3.1.1.2 RUN apk -U add \ alsa-lib \ - dbus \ - popt \ - glib \ - soxr \ avahi \ avahi-tools \ - libconfig \ - libsndfile \ - mosquitto \ - libuuid \ + dbus \ ffmpeg \ - libsodium \ - libgcrypt \ - libressl3.6-libcrypto \ - libplist \ - mandoc \ - man-pages \ + glib \ less \ - less-doc + less-doc \ + libconfig \ + libgcrypt \ + libplist \ + libpulse \ + libressl3.6-libcrypto \ + libsndfile \ + libsodium \ + libuuid \ + man-pages \ + mandoc \ + mosquitto \ + popt \ + soxr # Copy build files. COPY --from=builder /shairport-sync/build/install/usr/local/bin/shairport-sync /usr/local/bin/shairport-sync @@ -100,6 +102,7 @@ COPY --from=builder /shairport-sync/build/install/etc/dbus-1/system.d/shairport- 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 +COPY ./docker/etc/pulse /etc/pulse RUN chmod +x /etc/s6-overlay/s6-rc.d/01-startup/script.sh # Create non-root user for running the container -- running as the user 'shairport-sync' also allows diff --git a/docker/README.md b/docker/README.md index 560dc89b..6caf1c4d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -40,6 +40,8 @@ $ docker run -d --restart unless-stopped --net host --device /dev/snd \ ``` 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. +The image is built with PulseAudio backend support. To use it, refer to [`docker-compose.yaml`](docker-compose.yaml) for required environment variables and mounts. You might need to adjust authentication on your PulseAudio server ([PA documentation](https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-native-protocol-unixtcp)) and set default backend to `pa` via either command line option `-o` or `general.output_backend` field in config file. + ## Configuration File To get access to the full range of configuration options, pass the configuration file to `/etc/shairport-sync.conf` in the container using the `-v` option or docker compose. diff --git a/docker/classic/Dockerfile b/docker/classic/Dockerfile index 3d072a55..960822f3 100644 --- a/docker/classic/Dockerfile +++ b/docker/classic/Dockerfile @@ -8,20 +8,21 @@ ARG SHAIRPORT_SYNC_BRANCH RUN test -n "$SHAIRPORT_SYNC_BRANCH" RUN apk -U add \ - git \ - build-base \ + alsa-lib-dev \ autoconf \ automake \ - libtool \ - dbus \ - alsa-lib-dev \ - popt-dev \ - mbedtls-dev \ - soxr-dev \ avahi-dev \ + build-base \ + dbus \ + git \ libconfig-dev \ + libsndfile-dev \ + libtool \ + mbedtls-dev \ mosquitto-dev \ - libsndfile-dev + popt-dev \ + pulseaudio-dev \ + soxr-dev ##### ALAC ##### RUN git clone https://github.com/mikebrady/alac @@ -39,7 +40,7 @@ COPY . . RUN git checkout "$SHAIRPORT_SYNC_BRANCH" WORKDIR /shairport-sync/build RUN autoreconf -i ../ -RUN ../configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=mbedtls \ +RUN ../configure --sysconfdir=/etc --with-alsa --with-pa --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 @@ -53,20 +54,21 @@ FROM crazymax/alpine-s6:3.17-3.1.1.2 RUN apk -U add \ alsa-lib \ - dbus \ - popt \ - glib \ - mbedtls \ - soxr \ avahi \ avahi-tools \ - libconfig \ - mosquitto \ - libsndfile-dev \ - mandoc \ - man-pages \ + dbus \ + glib \ less \ - less-doc + less-doc \ + libconfig \ + libsndfile-dev \ + libpulse \ + man-pages \ + mandoc \ + mbedtls \ + mosquitto \ + popt \ + soxr # Copy build files. COPY --from=builder /shairport-sync/build/install/usr/local/bin/shairport-sync /usr/local/bin/shairport-sync diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 88831298..563622d6 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -5,10 +5,14 @@ services: image: mikebrady/shairport-sync:latest network_mode: host restart: unless-stopped + # environment: + # PULSE_SERVER: unix:/tmp/pulseaudio.socket # Path for PulseAudio socket + # PULSE_COOKIE: /tmp/pulseaudio.cookie # Path for PulseAudio cookie devices: - - "/dev/snd" + - "/dev/snd" # ALSA device # volumes: # - ./volumes/shairport-sync/shairport-sync.conf:/etc/shairport-sync.conf # Customised Shairport Sync configuration file. + # - /run/user/1000/pulse/native:/tmp/pulseaudio.socket # PulseAudio socket when using that backend logging: options: max-size: "200k" diff --git a/docker/etc/pulse/client.conf b/docker/etc/pulse/client.conf new file mode 100644 index 00000000..5fbb34d1 --- /dev/null +++ b/docker/etc/pulse/client.conf @@ -0,0 +1,6 @@ +default-server = unix:/tmp/pulseaudio.socket +# Prevent a server running in the container +autospawn = no +daemon-binary = /bin/true +# Prevent the use of shared memory +enable-shm = false