yubiuser / librespot-shairport-snapserver

Docker image combining librespot shairport-sync and snapserver
0 stars 1 forks source link

Add python dependencies for meta plugins #73

Open jojo141185 opened 1 month ago

jojo141185 commented 1 month ago

Hello Yubiuser, many thanks for providing this docker container. Is it possible to add the necessary dependencies to use the meta plugins, like meta_mpd.py and meta_mopidy.py, by controlscript that are shipped with the snapserver installation?

The current dependencies are:

RUN apk add --no-cache \
    # Python dependencies
    py3-gobject3

# Install python dependencies for control scripts
RUN python3 -m pip install \
    python-mpd2 \
    musicbrainzngs \
    websocket-client \
    requests
yubiuser commented 1 month ago

Thanks for your suggestion. I added the dependencies (see https://github.com/yubiuser/librespot-shairport-snapserver/pull/74) and it builds successfully. Have you tried it locally and tested if the scripts work on the container as expected?

To be honest, I hesitate to add the dependencies, as it requires python3 to be installed as well - which blows up the image size from 110 to 210 MB....

jojo141185 commented 1 month ago

Thanks for the quick integration as PR! I'm currently using Jaedb's Snapserver Docker container and the Python meta plugin works perfectly in combination with Mopidy and Iris WebUI. Unfortunately, its image is not very up-to-date, so I'm currently looking for an alternative. To reduce the image size, it probably makes sense to use a base image that already has the necessary python3 packages integrated, e.g. python:3.12-alpine. You could also try reducing the number of layers and removing the APK and pip cache (--no-cache) to further reduce the overall size of the image.

yubiuser commented 4 weeks ago

If you look at the docker file, it is already optimized for small image size (e.g. everything is build in different stages and only copied over at the final stage; apk already uses --no-cache and the packages are cleared). Adding the dependencies adds 90MB

chris@T14Gen5:~/Software/Github repositories/librespot-shairport-snapserver$ docker history 5852a057517d
IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
5852a057517d   38 hours ago   ENTRYPOINT ["/init"]                            0B        buildkit.dockerfile.v0
<missing>      38 hours ago   RUN /bin/sh -c mkdir -p /var/run/dbus/ # bui…   0B        buildkit.dockerfile.v0
<missing>      38 hours ago   RUN /bin/sh -c chmod +x /etc/s6-overlay/s6-r…   36B       buildkit.dockerfile.v0
<missing>      38 hours ago   COPY ./s6-overlay/s6-rc.d /etc/s6-overlay/s6…   1.11kB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /nqptp/nqptp /usr/local/bin/ # buildkit    115kB     buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /shairport/build/shairport-sync /usr/lo…   1.37MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /snapweb/dist /usr/share/snapserver/sna…   1.04MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /snapcast/bin/snapserver /usr/local/bin…   6.61MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /librespot/target/release/librespot /us…   8.71MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /tmp-libs/ /usr/lib/ # buildkit            82.5MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY init /init # buildkit                      1.01kB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /etc/s6-overlay/ /etc/s6-overlay/ # bui…   14B       buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /package/ /package/ # buildkit             5.11MB    buildkit.dockerfile.v0
<missing>      38 hours ago   COPY /command /command/ # buildkit              0B        buildkit.dockerfile.v0
<missing>      38 hours ago   RUN /bin/sh -c apk add --no-cache     python…   89.9MB    buildkit.dockerfile.v0
<missing>      38 hours ago   RUN /bin/sh -c echo "@testing https://dl-cdn…   163B      buildkit.dockerfile.v0
<missing>      38 hours ago   RUN /bin/sh -c apk add --no-cache           …   2.11MB    buildkit.dockerfile.v0
<missing>      38 hours ago   ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0          0B        buildkit.dockerfile.v0
<missing>      38 hours ago   ENV S6_CMD_WAIT_FOR_SERVICES=1                  0B        buildkit.dockerfile.v0
<missing>      3 weeks ago    /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B        
<missing>      3 weeks ago    /bin/sh -c #(nop) ADD file:99093095d62d04215…   7.8MB    

__

I tried with python:3.12-alpine but did not succeed with the snippet you provided above.

RUN apk add --no-cache \
    # Python dependencies
    py3-gobject3

The issue is that py3-gobject3 has python as a requirement which will install it from alpine repos depsite python being available from the base image. Using pip´ to install the bindingsPyGObject` requires a lot of extra packages, was there is no wheel for it and it needs to be compiled from source.