latest fixes to dockerfile
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 5 Nov 2020 19:24:14 +0000 (20:24 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 5 Nov 2020 19:24:14 +0000 (20:24 +0100)
stick with debian base image for max compatibility

.gitignore
Dockerfile [changed mode: 0755->0644]
Dockerfile.alpine [new file with mode: 0755]
Dockerfile.debian [deleted file]
music_assistant/providers/spotify/__init__.py
music_assistant/providers/spotify/spotty/darwin/spotty [deleted file]
music_assistant/providers/spotify/spotty/linux/spotty-armv6 [deleted file]
music_assistant/providers/spotify/spotty/linux/spotty-muslhf [deleted file]
music_assistant/providers/spotify/spotty/osx/spotty [new file with mode: 0755]
music_assistant/web/endpoints/playlists.py

index f8f10376e7adca70432438ec08567aeac9a32c6d..8e3aed5b27af57b616c848873adb367cbf347c80 100644 (file)
@@ -13,3 +13,4 @@ venv/
 .mypy_cache/
 .tox/
 *.egg-info/
+*.spec
old mode 100755 (executable)
new mode 100644 (file)
index eaa9030..04c6371
@@ -1,71 +1,71 @@
-FROM python:3.8-alpine3.12
+FROM python:3.8-slim as builder
 
+ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple
+
+RUN set -x \
+    # Install buildtime packages
+    && apt-get update && apt-get install -y --no-install-recommends \
+        curl \
+        ca-certificates \
+        build-essential \
+        gcc \
+        libtag1-dev \
+        libffi-dev \
+        libssl-dev \
+        zlib1g-dev \
+        xvfb \
+        tcl8.6-dev \
+        tk8.6-dev \
+        libjpeg-turbo-progs \
+        libjpeg62-turbo-dev
+
+# build jemalloc
 ARG JEMALLOC_VERSION=5.2.1
-WORKDIR /tmp
-COPY . .
+RUN curl -L -s https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2 \
+        | tar -xjf - -C /tmp \
+    && cd /tmp/jemalloc-${JEMALLOC_VERSION} \
+    && ./configure \
+    && make \
+    && make install
+
+# build python wheels
+WORKDIR /wheels
+COPY . /tmp
+RUN pip wheel uvloop cchardet aiodns brotlipy \
+    && pip wheel -r /tmp/requirements.txt \
+    # Include frontend-app in the source files
+    && curl -L https://github.com/music-assistant/app/archive/master.tar.gz | tar xz \
+    && mv app-master/docs /tmp/music_assistant/web/static \
+    && pip wheel /tmp
+    
+#### FINAL IMAGE
+FROM python:3.8-slim AS final-image
 
-# Install packages
+WORKDIR /wheels
+COPY --from=builder /wheels /wheels
+COPY --from=builder /usr/local/lib/libjemalloc.so /usr/local/lib/libjemalloc.so
 RUN set -x \
-    && apk update \
-    && echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
-    && echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
-    # install default packages
-    && apk add --no-cache \
+    # Install runtime dependency packages
+    && apt-get update \
+    && apt-get install -y --no-install-recommends \
+        curl \
         tzdata \
         ca-certificates \
-        curl \
         flac \
         sox \
-        libuv \
+        libsox-fmt-all \
         ffmpeg \
-        uchardet \
-        # dependencies for pillow
-        freetype \
-        lcms2 \
-        libimagequant \
-        libjpeg-turbo \
-        libwebp \
-        libxcb \
-        openjpeg \
-        tiff \
-        zlib \
-    # install (temp) build packages
-    && apk add --no-cache --virtual .build-deps \
-        build-base \
-        libsndfile-dev \
-        taglib-dev \
-        gcc \
-        musl-dev \
-        freetype-dev \
-        libpng-dev \
-        libressl-dev \
-        fribidi-dev \
-        harfbuzz-dev \
-        jpeg-dev \
-        lcms2-dev \
-        openjpeg-dev \
-        tcl-dev \
-        tiff-dev \
-        tk-dev \
-        zlib-dev \
-        libuv-dev \
-        libffi-dev \
-        uchardet-dev \
-    # setup jemalloc
-    && curl -L -f -s "https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" \
-            | tar -xjf - -C /tmp \
-        && cd /tmp/jemalloc-${JEMALLOC_VERSION} \
-        && ./configure \
-        && make \
-        && make install \
-        && cd /tmp \
-    # make sure optional packages are installed
-    && pip install uvloop cchardet aiodns brotlipy \
-    # install music assistant
-    && pip install . \
-    # cleanup build files
-    && apk del .build-deps \
-    && rm -rf /tmp/*
+        libtag1v5 \
+        openssl \
+        libjpeg62-turbo \
+        zlib1g \
+    # install music assistant (and all it's dependencies) using the prebuilt wheels
+    && pip install --no-cache-dir -f /wheels music_assistant \
+    # cleanup
+    && rm -rf /tmp/* \
+    && rm -rf /wheels \
+    && rm -rf /var/lib/apt/lists/* \
+    && rm -rf /root/*
 
 ENV DEBUG=false
 EXPOSE 8095/tcp
diff --git a/Dockerfile.alpine b/Dockerfile.alpine
new file mode 100755 (executable)
index 0000000..8544c7c
--- /dev/null
@@ -0,0 +1,78 @@
+FROM python:3.8-alpine3.12
+
+ARG JEMALLOC_VERSION=5.2.1
+WORKDIR /tmp
+COPY . .
+
+# Install packages
+RUN set -x \
+    && apk update \
+    && echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
+    && echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
+    # install default packages
+    && apk add --no-cache \
+        tzdata \
+        ca-certificates \
+        curl \
+        flac \
+        sox \
+        libuv \
+        ffmpeg \
+        uchardet \
+        taglib \
+        libressl \
+        # dependencies for pillow
+        freetype \
+        lcms2 \
+        libimagequant \
+        libjpeg-turbo \
+        libwebp \
+        libxcb \
+        openjpeg \
+        tiff \
+        zlib \
+    # install (temp) build packages
+    && apk add --no-cache --virtual .build-deps \
+        build-base \
+        libsndfile-dev \
+        taglib-dev \
+        gcc \
+        musl-dev \
+        freetype-dev \
+        libpng-dev \
+        libressl-dev \
+        fribidi-dev \
+        harfbuzz-dev \
+        jpeg-dev \
+        lcms2-dev \
+        openjpeg-dev \
+        tcl-dev \
+        tiff-dev \
+        tk-dev \
+        zlib-dev \
+        libuv-dev \
+        libffi-dev \
+        uchardet-dev \
+    # setup jemalloc
+    && curl -L -f -s "https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2" \
+            | tar -xjf - -C /tmp \
+        && cd /tmp/jemalloc-${JEMALLOC_VERSION} \
+        && ./configure \
+        && make \
+        && make install \
+        && cd /tmp \
+    # make sure optional packages are installed
+    && pip install uvloop cchardet aiodns brotlipy \
+    # install music assistant
+    && pip install . \
+    # cleanup build files
+    && apk del .build-deps \
+    && rm -rf /tmp/*
+
+ENV DEBUG=false
+EXPOSE 8095/tcp
+
+VOLUME [ "/data" ]
+
+ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
+ENTRYPOINT ["mass", "--config", "/data"]
\ No newline at end of file
diff --git a/Dockerfile.debian b/Dockerfile.debian
deleted file mode 100644 (file)
index ed5c06c..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-FROM python:3.8-slim as builder
-
-RUN set -x \
-    # Install buildtime packages
-    && apt-get update && apt-get install -y --no-install-recommends \
-        curl \
-        ca-certificates \
-        build-essential \
-        gcc \
-        libtag1-dev \
-        libffi-dev \
-        openssl-dev
-
-# build jemalloc
-ARG JEMALLOC_VERSION=5.2.1
-RUN curl -L -s https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2 \
-        | tar -xjf - -C /tmp \
-    && cd /tmp/jemalloc-${JEMALLOC_VERSION} \
-    && ./configure \
-    && make \
-    && make install
-
-# build python wheels
-WORKDIR /wheels
-COPY . /tmp
-RUN pip wheel uvloop cchardet aiodns brotlipy \
-    && pip wheel --extra-index-url=https://www.piwheels.org/simple -r /tmp/requirements.txt \
-    # Include frontend-app in the source files
-    && curl -L https://github.com/music-assistant/app/archive/master.tar.gz | tar xz \
-    && mv app-master/docs /tmp/music_assistant/web/static \
-    && pip wheel --extra-index-url=https://www.piwheels.org/simple /tmp
-    
-#### FINAL IMAGE
-FROM python:3.8-slim
-
-WORKDIR /wheels
-COPY --from=builder /wheels /wheels
-COPY --from=builder /usr/local/lib/libjemalloc.so /usr/local/lib/libjemalloc.so
-RUN set -x \
-    # Install runtime dependency packages
-    && apt-get update \
-    && apt-get install -y --no-install-recommends \
-        curl \
-        tzdata \
-        ca-certificates \
-        flac \
-        sox \
-        libsox-fmt-all \
-        ffmpeg \
-        libtag1v5 \
-        openssl \
-    # install music assistant (and all it's dependencies) using the prebuilt wheels
-    && pip install --no-cache-dir -f /wheels --extra-index-url=https://www.piwheels.org/simple music_assistant \
-    # cleanup
-    && rm -rf /tmp/* \
-    && rm -rf /wheels \
-    && rm -rf /var/lib/apt/lists/*
-
-ENV DEBUG=false
-EXPOSE 8095/tcp
-
-VOLUME [ "/data" ]
-
-ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
-ENTRYPOINT ["mass", "--config", "/data"]
\ No newline at end of file
index c71f9bad6defecaad9e46f0ecb9ae167c098d8e3..e089db6194c94f8a770ae08ec6e0e29a1120db4a 100644 (file)
@@ -315,10 +315,13 @@ class SpotifyProvider(MusicProvider):
         # make sure that the token is still valid by just requesting it
         await self.async_get_token()
         spotty = self.get_spotty_binary()
-        spotty_exec = '%s -n temp -c "%s" --pass-through --single-track %s' % (
-            spotty,
-            self.mass.config.data_path,
-            track.item_id,
+        spotty_exec = (
+            '%s -n temp -c "%s" --pass-through --single-track spotify://track:%s'
+            % (
+                spotty,
+                self.mass.config.data_path,
+                track.item_id,
+            )
         )
         return StreamDetails(
             type=StreamType.EXECUTABLE,
@@ -621,7 +624,7 @@ class SpotifyProvider(MusicProvider):
             )
         if platform.system() == "Darwin":
             # macos binary is x86_64 intel
-            return os.path.join(os.path.dirname(__file__), "spotty", "darwin", "spotty")
+            return os.path.join(os.path.dirname(__file__), "spotty", "osx", "spotty")
         if platform.system() == "Linux":
             architecture = platform.machine()
             if architecture in ["AMD64", "x86_64"]:
@@ -637,10 +640,10 @@ class SpotifyProvider(MusicProvider):
             if "aarch64" in architecture or "armv8" in architecture:
                 # arm64 linux binary
                 return os.path.join(
-                    os.path.dirname(__file__), "spotty", "x86-linux", "spotty-aarch64"
+                    os.path.dirname(__file__), "spotty", "linux", "spotty-aarch64"
                 )
             # assume armv7
             return os.path.join(
-                os.path.dirname(__file__), "spotty", "arm-linux", "spotty-armhf"
+                os.path.dirname(__file__), "spotty", "linux", "spotty-armhf"
             )
         return None
diff --git a/music_assistant/providers/spotify/spotty/darwin/spotty b/music_assistant/providers/spotify/spotty/darwin/spotty
deleted file mode 100755 (executable)
index e20a0d9..0000000
Binary files a/music_assistant/providers/spotify/spotty/darwin/spotty and /dev/null differ
diff --git a/music_assistant/providers/spotify/spotty/linux/spotty-armv6 b/music_assistant/providers/spotify/spotty/linux/spotty-armv6
deleted file mode 100755 (executable)
index 3b474e5..0000000
Binary files a/music_assistant/providers/spotify/spotty/linux/spotty-armv6 and /dev/null differ
diff --git a/music_assistant/providers/spotify/spotty/linux/spotty-muslhf b/music_assistant/providers/spotify/spotty/linux/spotty-muslhf
deleted file mode 100755 (executable)
index c172724..0000000
Binary files a/music_assistant/providers/spotify/spotty/linux/spotty-muslhf and /dev/null differ
diff --git a/music_assistant/providers/spotify/spotty/osx/spotty b/music_assistant/providers/spotify/spotty/osx/spotty
new file mode 100755 (executable)
index 0000000..e20a0d9
Binary files /dev/null and b/music_assistant/providers/spotify/spotty/osx/spotty differ
index b5830ba85b428a6539abd8dfcc19a87668c7e0f9..ac152b85573351d23a3f547f0e5277b1723a4701 100644 (file)
@@ -3,6 +3,7 @@
 import ujson
 from aiohttp.web import Request, Response, RouteTableDef, json_response
 from aiohttp_jwt import login_required
+from music_assistant.helpers.util import json_serializer
 from music_assistant.helpers.web import async_media_items_from_body, async_stream_json
 
 routes = RouteTableDef()
@@ -17,7 +18,7 @@ async def async_playlist(request: Request):
     if item_id is None or provider is None:
         return Response(text="invalid item or provider", status=501)
     result = await request.app["mass"].music.async_get_playlist(item_id, provider)
-    return json_response(result)
+    return json_response(result, dumps=json_serializer)
 
 
 @routes.get("/api/playlists/{item_id}/tracks")