FROM archlinux:latest

ENV DEBIAN_FRONTEND=noninteractive
ENV UNAME user

RUN useradd -u 1001 -m -d /home/user -s /bin/sh user && \
    usermod -aG audio user
RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

WORKDIR /usr/src/app


RUN pacman -Syud --noconfirm \
    base-devel git \
    nodejs yarn node-gyp \
    pulseaudio \
    mpv rtmpdump aria2

RUN mkdir /opt/ytdl && chown user:user /opt/ytdl
USER user
RUN git clone https://aur.archlinux.org/yt-dlp.git /opt/ytdl && \
    cd /opt/ytdl && makepkg -sci --noconfirm && sudo ln -s /usr/bin/yt-dlp /usr/bin/youtube-dl
USER root

COPY package*.json ./
RUN yarn install

COPY . .
RUN chmod +x run.sh



CMD [ "./run.sh" ]
