From: Marcel van der Veldt Date: Thu, 5 Nov 2020 19:24:14 +0000 (+0100) Subject: latest fixes to dockerfile X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=014f9daf01d740eee6cdba7f4c230efee372adc9;p=music-assistant-server.git latest fixes to dockerfile stick with debian base image for max compatibility --- diff --git a/.gitignore b/.gitignore index f8f10376..8e3aed5b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ venv/ .mypy_cache/ .tox/ *.egg-info/ +*.spec diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index eaa90307..04c6371c --- a/Dockerfile +++ b/Dockerfile @@ -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 index 00000000..8544c7c4 --- /dev/null +++ b/Dockerfile.alpine @@ -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 index ed5c06c7..00000000 --- a/Dockerfile.debian +++ /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 diff --git a/music_assistant/providers/spotify/__init__.py b/music_assistant/providers/spotify/__init__.py index c71f9bad..e089db61 100644 --- a/music_assistant/providers/spotify/__init__.py +++ b/music_assistant/providers/spotify/__init__.py @@ -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 index e20a0d91..00000000 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 index 3b474e5d..00000000 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 index c172724f..00000000 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 index 00000000..e20a0d91 Binary files /dev/null and b/music_assistant/providers/spotify/spotty/osx/spotty differ diff --git a/music_assistant/web/endpoints/playlists.py b/music_assistant/web/endpoints/playlists.py index b5830ba8..ac152b85 100644 --- a/music_assistant/web/endpoints/playlists.py +++ b/music_assistant/web/endpoints/playlists.py @@ -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")