# Base on latest (edge) alpine image
FROM harbor.ervine.dev/public/x86_64/alpine:v3.13.5

LABEL maintainer="Jonathan Ervine docker@ervine.org"

# Install updates
ENV LANG='en_US.UTF-8' \
    LANGUAGE='en_US.UTF-8' \
    TERM='xterm' \
    VERSION='3' \
    MONO_TLS_PROVIDER=legacy

RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
  apk -U update && \
  apk -U upgrade --ignore alpine-baselayout && \
  apk -U add libmediainfo ca-certificates mono zip curl libgdiplus && \
  apk del make gcc g++ && \
  cert-sync /etc/ssl/certs/ca-certificates.crt
  rm -rf /tmp/src && \
  rm -rf /var/cache/apk/*

RUN curl -sLo sonarr.tar.gz https://download.sonarr.tv/v3/main/3.0.6.1342/Sonarr.main.3.0.6.1342.linux.tar.gz && \
  sleep 30 && \
  tar zxvf sonarr.tar.gz && \
  rm -rf sonarr.tar.gz && \
  addgroup -g 1027 sonarr && \
  adduser -D -u 1027 -G sonarr -H sonarr && \
  chown -R sonarr:sonarr /Sonarr

EXPOSE 8989

USER sonarr

CMD [ "/usr/bin/mono", "--debug", "/Sonarr/Sonarr.exe", "--nobrowser", "--data=/config" ]
