FROM archlinux:latest
WORKDIR /config
USER root
RUN mkdir /init2 && mkdir /system
COPY . /init2/

ARG EMBY_V=4.9.0.42
ARG FFMPEG_V=2023_06_25

ENV TZ=Asia/Shanghai
ENV http_proxy="http://10.168.1.192:10810"
ENV https_proxy="http://10.168.1.192:10810"
ENV ftp_proxy="http://10.168.1.192:10810"

ENV FFDETECT=/usr/bin/ffdetect
ENV FFMPEG=/usr/bin/ffmpeg
ENV FFPROBE=/usr/bin/ffprobe
ENV PROGRAM_DATA=/config
ENV LIBVA_DRIVERS_PATH=/usr/lib/dri
ENV LD_LIBRARY_PATH=/usr/lib

ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-amd64-installer /tmp/
RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer /

RUN mkdir -p /etc/services.d/emby-server-s6/ && cp /init2/run /etc/services.d/emby-server-s6 && cp /init2/finish /etc/services.d/emby-server-s6 && chmod u+x /etc/services.d/emby-server-s6/*
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "use_proxy=on" >> /etc/wgetrc && echo "http_proxy=http://10.168.1.192:10810/" >> /etc/wgetrc && echo "https_proxy=http://10.168.1.192:10810/" >> /etc/wgetrc && echo "ftp_proxy=http://10.168.1.192:10810/" >> /etc/wgetrc && echo "wait=10" >> /etc/wgetrc
RUN pacman -Syu --noconfirm && pacman -Sy --noconfirm alsa-lib aom aspnet-runtime-8.0 bzip2 dotnet-runtime-8.0 expat fontconfig fribidi glibc gmp gnutls lame libass chromaprint dav1d libdrm freetype2 libjpeg-turbo libmfx libpng tesseract libtheora libva libvips libvorbis libwebp x264 x265 ocl-icd opus skia-sharp sqlite zvbi zlib
RUN pacman -Sy --noconfirm intel-compute-runtime intel-media-driver onevpl-intel-gpu libva-utils wget unzip nano

# RUN wget https://github.com/MediaBrowser/Emby.Releases/releases/download/${EMBY_V}/embyserver-netcore_${EMBY_V}.zip && unzip -d / embyserver-netcore_${EMBY_V}.zip && chmod -R u+x /system
# RUN wget https://mediabrowser.github.io/embytools/ffmpeg-${FFMPEG_V}-x64.tar.xz && tar xvf ffmpeg-${FFMPEG_V}-x64.tar.xz -C / && chmod -R u+x /bin/ff*
RUN unzip -d / /init2/embyserver-netcore_${EMBY_V}.zip && chmod -R u+x /system
RUN tar xvf /init2/ffmpeg-${FFMPEG_V}-x64.tar.xz -C / && chmod -R u+x /bin/ff*
# install mannal !
# RUN pacman -Sy emby-server

# ENTRYPOINT ["s6-svscan"]
ENTRYPOINT ["/init"]
# docker build --progress=plain -t harbor.mb6.top/xinjiawei1/embyarch:3.0 .