Switch base image to Docker (#1629)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 29 Aug 2024 18:00:34 +0000 (20:00 +0200)
committerGitHub <noreply@github.com>
Thu, 29 Aug 2024 18:00:34 +0000 (20:00 +0200)
Dockerfile
music_assistant/server/helpers/util.py
music_assistant/server/providers/airplay/bin/cliraop-linux-aarch64 [changed mode: 0755->0644]
music_assistant/server/providers/airplay/bin/cliraop-linux-x86_64 [changed mode: 0755->0644]
scripts/setup.sh

index 39db3985be998f4e03ef45c930597112b4107828..0e65691d7edc81c530db9ad4694ddd743ba28f9a 100644 (file)
@@ -1,98 +1,45 @@
 # syntax=docker/dockerfile:1
-ARG TARGETPLATFORM
-ARG PYTHON_VERSION="3.12"
 
-#####################################################################
-#                                                                   #
-# Build Wheels                                                      #
-#                                                                   #
-#####################################################################
-FROM python:${PYTHON_VERSION}-slim as wheels-builder
-ARG TARGETPLATFORM
+FROM python:3.12-alpine3.20
 
-# Install buildtime packages
-RUN set -x \
-    && apt-get update \
-    && apt-get install -y --no-install-recommends \
-        build-essential \
-        libffi-dev \
-        cargo \
-        git \
-        curl
-
-WORKDIR /wheels
-COPY requirements_all.txt .
-
-
-# build python wheels for all dependencies
-RUN set -x \
-    && pip install --upgrade pip \
-    && pip install build maturin \
-    && pip wheel -r requirements_all.txt
-
-
-#####################################################################
-#                                                                   #
-# Final Image                                                       #
-#                                                                   #
-#####################################################################
-FROM python:${PYTHON_VERSION}-slim AS final-build
-WORKDIR /app
-
-# Required to persist build arg
-ARG MASS_VERSION
-ARG TARGETPLATFORM
+ARG MASS_VERSION=2.3.0b8
 
 RUN set -x \
-    && apt-get update \
-    && apt-get install -y --no-install-recommends \
+    && apk add --no-cache \
         ca-certificates \
+        jemalloc \
         curl \
         git \
         wget \
         tzdata \
-        libsox-fmt-all \
-        libsox3 \
         sox \
-        cifs-utils \
-        libnfs-utils \
-        libjemalloc2 \
-    # install snapcast server 0.27 from bookworm backports
-    && sh -c 'echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list' \
-    && apt-get update \
-    && apt-get install -y --no-install-recommends -t bookworm-backports snapserver \
-    # install ffmpeg 6 from multimedia repo
-    && sh -c 'echo "Types: deb\nURIs: https://www.deb-multimedia.org\nSuites: stable\nComponents: main non-free\nSigned-By: /etc/apt/trusted.gpg.d/deb-multimedia-keyring.gpg" >> /etc/apt/sources.list.d/deb-multimedia.sources' \
-    && sh -c 'echo "Package: *\nPin: origin www.deb-multimedia.org\nPin-Priority: 1" >> /etc/apt/preferences.d/99deb-multimedia' \
-    && cd /tmp && curl -sLO https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb \
-    && apt install -y /tmp/deb-multimedia-keyring_2016.8.1_all.deb \
-    && apt-get update \
-    && apt install -y -t 'o=Unofficial Multimedia Packages' ffmpeg \
-    # cleanup
-    && rm -rf /tmp/* \
-    && rm -rf /var/lib/apt/lists/*
+        samba \
+    # install ffmpeg from community repo
+    && apk add ffmpeg --repository=https://dl-cdn.alpinelinux.org/alpine/v3.20/community \
+    # install snapcast from community repo
+    && apk add snapcast --repository=https://dl-cdn.alpinelinux.org/alpine/v3.20/community \
+    # install libnfs from community repo
+    && apk add libnfs --repository=https://dl-cdn.alpinelinux.org/alpine/v3.20/community
 
 # Copy widevine client files to container
 RUN mkdir -p /usr/local/bin/widevine_cdm
 COPY widevine_cdm/* /usr/local/bin/widevine_cdm/
 
-# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount
-# Install all built wheels
-RUN --mount=type=bind,target=/tmp/wheels,source=/wheels,from=wheels-builder,rw \
-    set -x \
-    && pip install --upgrade pip \
-    && pip install --no-cache-dir /tmp/wheels/*.whl
+# Upgrade pip + Install uv
+RUN pip install --upgrade pip \
+    && pip install uv==0.2.27
 
-# Install Music Assistant from published wheel
-RUN pip3 install \
-        --no-cache-dir \
-        music-assistant[server]==${MASS_VERSION} \
-    && python3 -m compileall music_assistant
+# Install Music Assistant from published wheel on PyPi
+RUN uv pip install \
+    --system \
+    --no-cache \
+    --find-links "https://wheels.home-assistant.io/musllinux/" \
+    music-assistant[server]==${MASS_VERSION}
 
-# Enable jemalloc
-RUN \
-    export LD_PRELOAD="$(find /usr/lib/ -name *libjemalloc.so.2)" \
-    export MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:20000,muzzy_decay_ms:20000"
+# Configure runtime environmental variables
+RUN export LD_PRELOAD="/usr/lib/libjemalloc.so.2" \
+    && export UV_SYSTEM_PYTHON="1" \
+    && export UV_BREAK_SYSTEM_PACKAGES==1"
 
 # Set some labels
 LABEL \
@@ -110,5 +57,6 @@ LABEL \
     io.hass.type="addon"
 
 VOLUME [ "/data" ]
+EXPOSE 8095
 
 ENTRYPOINT ["mass", "--config", "/data"]
index d3d0d1cb18f054ba643420b2c12b545756e24bd0..54ef01eadfb4a96be104b0c5fdbe51c43a80e08f 100644 (file)
@@ -39,7 +39,7 @@ HA_WHEELS = "https://wheels.home-assistant.io/musllinux/"
 async def install_package(package: str) -> None:
     """Install package with pip, raise when install failed."""
     LOGGER.debug("Installing python package %s", package)
-    args = ["pip", "install", "--find-links", HA_WHEELS, package]
+    args = ["uv", "pip", "install", "--no-cache", "--find-links", HA_WHEELS, package]
     return_code, output = await check_output(*args)
 
     if return_code != 0:
old mode 100755 (executable)
new mode 100644 (file)
index 6471e7b..21410d3
Binary files a/music_assistant/server/providers/airplay/bin/cliraop-linux-aarch64 and b/music_assistant/server/providers/airplay/bin/cliraop-linux-aarch64 differ
old mode 100755 (executable)
new mode 100644 (file)
index fe4b716..95424e6
Binary files a/music_assistant/server/providers/airplay/bin/cliraop-linux-x86_64 and b/music_assistant/server/providers/airplay/bin/cliraop-linux-x86_64 differ
index ad1587d2eb7222ef6a2346f5128c2c0c0a280bd7..53f161a18061e71bef9bc7e37e36990882a7d274 100755 (executable)
@@ -14,12 +14,13 @@ else
   echo "Creating Virtual environment..."
   python -m venv .venv
 fi
-echo "Activating virtual environment..."   
+echo "Activating virtual environment..."
 source .venv/bin/activate
 
 echo "Installing development dependencies..."
 
-pip install -e ".[server]"
-pip install -e ".[test]"
+pip install --upgrade pip
+pip install --upgrade uv
+uv pip install -e ".[server]"
+uv pip install -e ".[test]"
 pre-commit install
-pip install -r requirements_all.txt