changes to build strategy
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 13 Feb 2021 20:46:50 +0000 (21:46 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 13 Feb 2021 20:46:50 +0000 (21:46 +0100)
.github/workflows/docker-build alpine.yml [new file with mode: 0644]
.github/workflows/docker-build-multiarch.yml [deleted file]
.github/workflows/docker-build.yml [new file with mode: 0644]
.vscode/settings.json
Dockerfile
Dockerfile.alpine [deleted file]
music_assistant/constants.py
music_assistant/managers/music.py
music_assistant/managers/streams.py
requirements.txt

diff --git a/.github/workflows/docker-build alpine.yml b/.github/workflows/docker-build alpine.yml
new file mode 100644 (file)
index 0000000..8df67dd
--- /dev/null
@@ -0,0 +1,76 @@
+name: Build multiarch Docker image (Alpine based)
+
+on:
+  push:
+  release:
+    types: [published, prereleased]
+  workflow_dispatch:
+    inputs:
+      logLevel:
+        description: 'Log level'     
+        required: true
+        default: 'warning'
+      tag:
+        description: 'Tag to set on docker image (e.g. 0.0.1'
+        required: true
+
+jobs:
+  buildx:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Prepare
+        id: prep
+        run: |
+          DOCKER_IMAGE=musicassistant/music-assistant
+          VERSION=latest
+          SHORTREF=${GITHUB_SHA::8}
+          MANUAL_TAG=${{ github.event.inputs.tag }}
+
+          # If a manual tag was supplied, use that
+          if [[ -n $MANUAL_TAG ]]; then
+            VERSION=${MANUAL_TAG}
+
+          # If this is git tag, use the tag name as a docker tag
+          elif [[ $GITHUB_REF == refs/tags/* ]]; then
+            VERSION=${GITHUB_REF#refs/tags/}
+          fi
+          TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
+
+          # If the VERSION looks like a version number, assume that
+          # this is the most recent version of the image and also
+          # tag it 'latest'.
+          if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
+            TAGS="$TAGS,${DOCKER_IMAGE}:latest"
+          fi
+
+          # Set output parameters.
+          echo ::set-output name=tags::${TAGS}
+          echo ::set-output name=docker_image::${DOCKER_IMAGE}
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+        with:
+          platforms: all
+
+      - name: Set up Docker Buildx
+        id: buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1 
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Build
+        uses: docker/build-push-action@v2
+        with:
+          builder: ${{ steps.buildx.outputs.name }}
+          context: .
+          file: ./Dockerfile.alpine
+          platforms: linux/amd64,linux/arm/v7,linux/arm64
+          push: true
+          tags: ${{ steps.prep.outputs.tags }}
diff --git a/.github/workflows/docker-build-multiarch.yml b/.github/workflows/docker-build-multiarch.yml
deleted file mode 100644 (file)
index 986c7e0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-name: Build multiarch Docker image
-
-on:
-  release:
-    types: [published, prereleased]
-  workflow_dispatch:
-    inputs:
-      logLevel:
-        description: 'Log level'     
-        required: true
-        default: 'warning'
-      tag:
-        description: 'Tag to set on docker image (e.g. 0.0.1'
-        required: true
-
-jobs:
-  buildx:
-    runs-on: ubuntu-latest
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v2
-
-      - name: Prepare
-        id: prep
-        run: |
-          DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/music-assistant
-          VERSION=latest
-          SHORTREF=${GITHUB_SHA::8}
-          MANUAL_TAG=${{ github.event.inputs.tag }}
-
-          # If a manual tag was supplied, use that
-          if [[ -n $MANUAL_TAG ]]; then
-            VERSION=${MANUAL_TAG}
-
-          # If this is git tag, use the tag name as a docker tag
-          elif [[ $GITHUB_REF == refs/tags/* ]]; then
-            VERSION=${GITHUB_REF#refs/tags/}
-          fi
-          TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
-
-          # If the VERSION looks like a version number, assume that
-          # this is the most recent version of the image and also
-          # tag it 'latest'.
-          if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
-            TAGS="$TAGS,${DOCKER_IMAGE}:latest"
-          fi
-
-          # Set output parameters.
-          echo ::set-output name=tags::${TAGS}
-          echo ::set-output name=docker_image::${DOCKER_IMAGE}
-
-      - name: Set up QEMU
-        uses: docker/setup-qemu-action@master
-        with:
-          platforms: all
-
-      - name: Set up Docker Buildx
-        id: buildx
-        uses: docker/setup-buildx-action@master
-
-      - name: Login to DockerHub
-        if: github.event_name != 'pull_request'
-        uses: docker/login-action@v1
-        with:
-          username: ${{ secrets.DOCKER_USERNAME }}
-          password: ${{ secrets.DOCKER_PASSWORD }}
-
-      - name: Build
-        uses: docker/build-push-action@v2
-        with:
-          builder: ${{ steps.buildx.outputs.name }}
-          context: .
-          file: ./Dockerfile
-          platforms: linux/amd64,linux/arm/v7,linux/arm64
-          push: true
-          tags: ${{ steps.prep.outputs.tags }}
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
new file mode 100644 (file)
index 0000000..5d5300e
--- /dev/null
@@ -0,0 +1,76 @@
+name: Build multiarch Docker image (Debian based)
+
+on:
+  push:
+  release:
+    types: [published, prereleased]
+  workflow_dispatch:
+    inputs:
+      logLevel:
+        description: 'Log level'     
+        required: true
+        default: 'warning'
+      tag:
+        description: 'Tag to set on docker image (e.g. 0.0.1'
+        required: true
+
+jobs:
+  buildx:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Prepare
+        id: prep
+        run: |
+          DOCKER_IMAGE=musicassistant/music-assistant-server
+          VERSION=latest
+          SHORTREF=${GITHUB_SHA::8}
+          MANUAL_TAG=${{ github.event.inputs.tag }}
+
+          # If a manual tag was supplied, use that
+          if [[ -n $MANUAL_TAG ]]; then
+            VERSION=${MANUAL_TAG}
+
+          # If this is git tag, use the tag name as a docker tag
+          elif [[ $GITHUB_REF == refs/tags/* ]]; then
+            VERSION=${GITHUB_REF#refs/tags/}
+          fi
+          TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
+
+          # If the VERSION looks like a version number, assume that
+          # this is the most recent version of the image and also
+          # tag it 'latest'.
+          if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
+            TAGS="$TAGS,${DOCKER_IMAGE}:latest"
+          fi
+
+          # Set output parameters.
+          echo ::set-output name=tags::${TAGS}
+          echo ::set-output name=docker_image::${DOCKER_IMAGE}
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+        with:
+          platforms: all
+
+      - name: Set up Docker Buildx
+        id: buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1 
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Build
+        uses: docker/build-push-action@v2
+        with:
+          builder: ${{ steps.buildx.outputs.name }}
+          context: .
+          file: ./Dockerfile
+          platforms: linux/amd64,linux/arm/v7,linux/arm64
+          push: true
+          tags: ${{ steps.prep.outputs.tags }}
index e1a9b44c3c92ded046a7b8fe0e480918e5692b6c..7e6073639bfa97738935be888a180404ff1514e8 100644 (file)
@@ -2,7 +2,7 @@
     "python.linting.pylintEnabled": true,
     "python.linting.pylintArgs": ["--rcfile=${workspaceFolder}/setup.cfg"],
     "python.linting.enabled": true,
-    "python.pythonPath": "venv/bin/python",
+    "python.pythonPath": "/Users/marcelvanderveldt/Workdir/music-assistant/server/.venv/bin/python3",
     "python.linting.flake8Enabled": true,
     "python.linting.flake8Args": ["--config=${workspaceFolder}/setup.cfg"],
     "python.linting.mypyEnabled": false,
index 05f2009fed59d9d2df9bbfbc5d95e4b3dd0733be..a1e4af3273dd8349a3dff4855cec759bc7e944f7 100644 (file)
@@ -1,78 +1,17 @@
-FROM python:3.8-slim as builder
+FROM musicassistant/base-image
 
-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
-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 \
-    && NB_CORES=$(grep -c '^processor' /proc/cpuinfo) \
-    && export MAKEFLAGS="-j$((NB_CORES+1)) -l${NB_CORES}" \
-    && make \
-    && make install
-
-# build python wheels
-WORKDIR /wheels
+# install latest version
 COPY . /tmp
-RUN pip wheel uvloop cchardet aiodns brotlipy \
-    && pip wheel -r /tmp/requirements.txt \
+RUN cd /tmp \
     # 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
-
-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 \
-        libjpeg62-turbo \
-        zlib1g \
-    # install music assistant (and all it's dependencies) using the prebuilt wheels
-    && pip install --no-cache-dir -f /wheels music_assistant \
+    && pip install --no-cache-dir music_assistant \
     # cleanup
-    && rm -rf /tmp/* \
-    && rm -rf /wheels \
-    && rm -rf /var/lib/apt/lists/* \
-    && rm -rf /root/*
+    && 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.alpine b/Dockerfile.alpine
deleted file mode 100755 (executable)
index 8544c7c..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-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
index 93738cea86e08b45dc6d735f582bdce9b60b3db6..d0e7efd33272ecee6c66b117f8f90dfca5cf6ff8 100755 (executable)
@@ -1,6 +1,6 @@
 """All constants for Music Assistant."""
 
-__version__ = "0.0.84"
+__version__ = "0.0.85"
 REQUIRED_PYTHON_VER = "3.7"
 
 # configuration keys/attributes
index d14c8cecd49fa6e5b03fce82b5b41a2dd4551913..8bb05a6068076975569cac6b4fdf05bfa5b6bee2 100755 (executable)
@@ -596,8 +596,9 @@ class MusicManager:
             if media_item.media_type == MediaType.Radio:
                 full_track = media_item
             else:
-                full_track = await self.async_get_track(
-                    media_item.item_id, media_item.provider
+                full_track = (
+                    await self.async_get_track(media_item.item_id, media_item.provider)
+                    or media_item
                 )
             # sort by quality and check track availability
             for prov_media in sorted(
index a0c810daf51f2473b6659b3274db8bc3b27a3d09..0ca98e6d308e4fc95896edcdfb8d41121e2555a8 100755 (executable)
@@ -14,7 +14,7 @@ import subprocess
 from enum import Enum
 from typing import AsyncGenerator, List, Optional, Tuple
 
-from aiofile import AIOFile, Reader
+import aiofiles
 from music_assistant.constants import (
     CONF_MAX_SAMPLE_RATE,
     EVENT_STREAM_ENDED,
@@ -376,8 +376,8 @@ class StreamManager:
                         audio_data += chunk
         # stream from file
         elif stream_type == StreamType.FILE:
-            async with AIOFile(stream_path) as afp:
-                async for chunk in Reader(afp):
+            async with aiofiles.open(stream_path) as afp:
+                async for chunk in afp:
                     yield chunk
                     if needs_analyze and len(audio_data) < 100000000:
                         audio_data += chunk
index 50eae7381beda5de149eab9792fc4526b692c18d..521ae59e6b155201e319c063e39f8b44da9de60d 100644 (file)
@@ -2,7 +2,7 @@ argparse==1.4.0
 aiohttp[speedups]==3.7.3
 pychromecast==8.1.0
 asyncio-throttle==1.0.1
-aiofile==3.3.3
+aiofiles==0.6.0
 aiosqlite==0.16.0
 pytaglib==1.4.6
 python-slugify==4.0.1