FROM alpine
RUN wget https://www.rarlab.com/rar/unrarsrc-6.0.7.tar.gz -O - | tar x -z -f -
RUN apk update;apk add g++ make
WORKDIR unrar
RUN make lib

FROM alpine
COPY --from=0 /unrar/libunrar.so /lib/libunrar.so
RUN apk update;apk add python3 imagemagick uwsgi-python3 uwsgi-http py3-pillow py3-pip py3-wheel py3-psycopg2 postgresql-client git
RUN mkdir /rpiwebapp
COPY ./requirements.txt /rpiwebapp
WORKDIR /rpiwebapp
RUN pip install -r requirements.txt
COPY . /rpiwebapp
VOLUME /srv/games /srv/comics /srv/movies /srv/tv
VOLUME /rpiwebapp/socket
EXPOSE 80
CMD ["uwsgi", "--plugin=http,python", "--processes=4", "--threads=2", "--http=:80", "--file=rpiWebApp.py", "--callable=app", "--enable-threads"]