# Builds a modified version of sabnzbd with nzbToMedia.
# Needs the configuration file mounted to /usr/local/scripts/autoProcessMedia.cfg
FROM lsiobase/ffmpeg:arm64v8-bin as binstage
FROM linuxserver/sabnzbd:latest

# Add files from binstage
COPY --from=binstage / /

# get the latest version from https://github.com/clinton-hall/nzbToMedia/tags
ENV GITTAG=12.1.10

RUN apk update && apk add \
  git \
  expat \
	fontconfig \
  ffmpeg \
  gcompat \
	glib-dev \
	libgomp \
  libc6-compat \
	harfbuzz \
	v4l-utils-libs \
	libx11 \
	libxcb \
	libxext \
	libxml2 && \
  echo "**** clean up ****" && \
  rm -rf /var/lib/apk/lists/* /var/tmp/*

WORKDIR /usr/local
RUN mkdir -p /usr/local/src/ \
    && curl -o /usr/local/src/nzbToMedia.tar.gz https://codeload.github.com/clinton-hall/nzbToMedia/tar.gz/refs/tags/${GITTAG} \
    && tar xvzf /usr/local/src/nzbToMedia.tar.gz \
    && mv nzbToMedia-${GITTAG} scripts \
    && cp scripts/autoProcessMedia.cfg.spec scripts/autoProcessMedia.cfg \
    && chown -R abc:abc scripts \
    && rm /usr/local/src/nzbToMedia.tar.gz

WORKDIR /
