From: Marcel van der Veldt Date: Thu, 9 Mar 2023 10:50:26 +0000 (+0100) Subject: try to fix docker build X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=30a162d35587dc8e85050ae80e6a95516438770a;p=music-assistant-server.git try to fix docker build --- diff --git a/Dockerfile b/Dockerfile index f7428c4e..5e6b07dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,93 @@ -FROM python:3.11.2 +# syntax=docker/dockerfile:experimental +ARG HASS_ARCH=amd64 +ARG BUILD_VERSION=latest +ARG PYTHON_VERSION="3.11" -# Install component packages -RUN \ - set -x \ +##################################################################### +# # +# Build Wheels # +# # +##################################################################### +FROM python:${PYTHON_VERSION}-slim as wheels-builder +ARG HASS_ARCH + +ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple +ENV PATH="${PATH}:/root/.cargo/bin" + +# Install buildtime packages +RUN set -x \ && apt-get update \ && apt-get install -y --no-install-recommends \ - libuv1 \ + build-essential \ + ca-certificates \ + curl \ + gcc \ + git \ + libffi-dev \ + libssl-dev + +RUN set -x \ + \ + && if [ ${HASS_ARCH} = "amd64" ]; then RUST_ARCH="x86_64-unknown-linux-gnu"; fi \ + && if [ ${HASS_ARCH} = "armv7" ]; then RUST_ARCH="armv7-unknown-linux-gnueabihf"; fi \ + && if [ ${HASS_ARCH} = "aarch64" ]; then RUST_ARCH="aarch64-unknown-linux-gnu"; fi \ + \ + && curl -o rustup-init https://static.rust-lang.org/rustup/dist/${RUST_ARCH}/rustup-init \ + && chmod +x rustup-init \ + && ./rustup-init -y --no-modify-path --profile minimal --default-host ${RUST_ARCH} + +WORKDIR /wheels +COPY requirements.txt . + +# build python wheels +RUN set -x \ + && pip wheel -r .[server] + + +##################################################################### +# # +# Final Image # +# # +##################################################################### +FROM python:${PYTHON_VERSION}-slim AS final-build +WORKDIR /app + +ENV DEBIAN_FRONTEND="noninteractive" + +RUN set -x \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ curl \ - wget \ - ffmpeg \ git \ - libjpeg62-turbo + jq \ + openssl \ + tzdata \ + ffmpeg \ + ffmpeg-libs \ + libjpeg-turbo \ + # cleanup + && rm -rf /tmp/* \ + && rm -rf /var/lib/apt/lists/* -COPY . ./ -# Install mass wheel and dependencies -RUN pip3 install --no-cache-dir .[server] +# 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 --no-cache-dir -f /tmp/wheels -r /tmp/wheels/requirements.txt + +# Required to persist build arg +ARG BUILD_VERSION +ARG HASS_ARCH +# Set some labels for the Home Assistant add-on +LABEL \ + io.hass.version=${BUILD_VERSION} \ + io.hass.name="Music Assistant" \ + io.hass.description="Music Assistant Server/Core" \ + io.hass.arch="${HASS_ARCH}" \ + io.hass.type="addon" EXPOSE 8095/tcp EXPOSE 9090/tcp diff --git a/compose.yml b/compose.yml deleted file mode 100644 index ca1a84ad..00000000 --- a/compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3.8" -services: - music-assistant-server: - build: - context: ./ - dockerfile: Dockerfile - image: music-assistant-server:latest - container_name: music-assistant-server - restart: unless-stopped - # Required for player discovery to work correctly - network_mode: host - volumes: - - ${USERDIR:-$HOME}/docker/music-assistant-server/data:/data/ diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 00000000..66ed7ca5 --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,13 @@ +version: "3" +services: + music-assistant-server: + build: + context: ./docker/ + dockerfile: Dockerfile + image: ghcr.io/music-assistant/core:latest # <<< Desired release version here + container_name: music-assistant-server + restart: unless-stopped + # Network mode must be set to host for MA to work correctly + network_mode: host + volumes: + - ${USERDIR:-$HOME}/docker/music-assistant-server/data:/data/ diff --git a/pyproject.toml b/pyproject.toml index d8d3fa9e..55881cb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ target-version = ['py311'] line-length = 100 [tool.codespell] -ignore-words-list = "provid" +ignore-words-list = "provid,hass" [tool.mypy] python_version = "3.11"