ARG BUILD_FROM=ghcr.io/hassio-addons/base:13.1.1
FROM ${BUILD_FROM}

RUN apk add --no-cache python3 zlib-dev libjpeg-turbo-dev gcc chromium chromium-chromedriver zstd linux-headers musl-dev

ADD rootfs /

RUN chmod 644 /usr/share/fontconfig/conf.avail/10-antialiasing.conf
RUN ln -s /usr/share/fontconfig/conf.avail/10-antialising.conf /etc/fonts/conf.d/10-antialiasing.conf

WORKDIR /app
RUN apk add --no-cache py3-pip py3-zstandard
RUN pip3 install -r requirements.txt

# Corrects permissions for s6 v3
RUN if [ -d /etc/cont-init.d ]; then chmod -R 755 /etc/cont-init.d; fi && \
    if [ -d /etc/services.d ]; then chmod -R 755 /etc/services.d; fi && \
    if [ -f /entrypoint.sh ]; then chmod 755 /entrypoint.sh; fi