diff --git a/dev.Dockerfile b/dev.Dockerfile index 460543e..53dff55 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -5,10 +5,23 @@ ARG DEV_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEB FROM ${DEV_IMAGE} +ARG TARGETPLATFORM +RUN echo "Building for ${TARGETPLATFORM:?}" + # Install debian packages RUN apt-get update -qq -RUN apt-get install -y inotify-tools ffmpeg curl git openssh-client jq \ - python3 python3-pip python3-setuptools python3-wheel python3-dev locales procps +RUN apt-get install -y inotify-tools curl git openssh-client jq \ + python3 python3-setuptools python3-wheel python3-dev pipx \ + python3-mutagen locales procps build-essential + +# Install ffmpeg +RUN export FFMPEG_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \ + "linux/amd64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz" ;; \ + "linux/arm64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz" ;; \ + *) echo "" ;; esac) && \ + curl -L ${FFMPEG_DOWNLOAD} --output /tmp/ffmpeg.tar.xz && \ + tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \ + tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffprobe" # Install nodejs RUN curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh @@ -21,16 +34,14 @@ RUN mix local.hex --force RUN mix local.rebar --force # Download and update YT-DLP -# NOTE: If you're seeing weird issues, consider using the FFMPEG released by yt-dlp RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp RUN chmod a+rx /usr/local/bin/yt-dlp RUN yt-dlp -U -# Download Apprise -RUN python3 -m pip install -U apprise --break-system-packages - -# Download Mutagen for music thumbnail generation -RUN python3 -m pip install -U mutagen --break-system-packages +# Install Apprise +RUN export PIPX_HOME=/opt/pipx && \ + export PIPX_BIN_DIR=/usr/local/bin && \ + pipx install apprise # Set the locale RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen diff --git a/selfhosted.Dockerfile b/selfhosted.Dockerfile index ce5b017..8a538ec 100644 --- a/selfhosted.Dockerfile +++ b/selfhosted.Dockerfile @@ -1,16 +1,5 @@ # Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian # instead of Alpine to avoid DNS resolution issues in production. -# -# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu -# https://hub.docker.com/_/ubuntu?tab=tags -# -# This file is based on these images: -# -# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image -# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20231009-slim - for the release image -# - https://pkgs.org/ - resource for finding needed packages -# - Ex: hexpm/elixir:1.16.0-erlang-26.2.1-debian-bullseye-20231009-slim -# ARG ELIXIR_VERSION=1.16.2 ARG OTP_VERSION=26.2.2 ARG DEBIAN_VERSION=bookworm-20240130-slim @@ -20,6 +9,9 @@ ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}" FROM ${BUILDER_IMAGE} as builder +ARG TARGETPLATFORM +RUN echo "Building for ${TARGETPLATFORM:?}" + # install build dependencies RUN apt-get update -y && \ # System packages @@ -35,19 +27,18 @@ RUN apt-get update -y && \ # Hex and Rebar mix local.hex --force && \ mix local.rebar --force && \ + # FFmpeg + export FFMPEG_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \ + "linux/amd64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz" ;; \ + "linux/arm64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz" ;; \ + *) echo "" ;; esac) && \ + curl -L ${FFMPEG_DOWNLOAD} --output /tmp/ffmpeg.tar.xz && \ + tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffmpeg" && \ + tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffprobe" && \ # Cleanup apt-get clean && \ rm -f /var/lib/apt/lists/*_* -# TODO: make this pull a different version of ffmpeg based on the architecture -# TODO: add to local dockerfile -# TODO: update docs -# TODO: update actions runner -RUN export FFMPEG_DOWNLOAD="https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz" && \ - curl -L ${FFMPEG_DOWNLOAD} --output /tmp/ffmpeg.tar.xz && \ - tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffmpeg" && \ - tar -xf /tmp/ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffprobe" - # prepare build dir WORKDIR /app @@ -147,11 +138,6 @@ COPY --from=builder /app/_build/${MIX_ENV}/rel/pinchflat ./ # root, use --user 0:0 or something. RUN passwd -d root -# If using an environment that doesn't automatically reap zombie processes, it is -# advised to add an init process such as tini via `apt-get install` -# above and adding an entrypoint. See https://github.com/krallin/tini for details -# ENTRYPOINT ["/tini", "--"] - HEALTHCHECK --interval=120s --start-period=10s \ CMD curl --fail http://localhost:${PORT}/healthcheck || exit 1