FROM archlinux:latest

# set mirror
RUN echo "Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
RUN pacman-key --init
RUN pacman -Sy --noconfirm archlinux-keyring && yes | pacman -Scc
RUN pacman -Syu --noconfirm ffmpeg && yes | pacman -Scc
# copy project files
COPY . /app
WORKDIR /app
RUN pacman -U python39-3.9.19-1-x86_64.pkg.tar.zst --noconfirm
RUN python3.9 pipx.pyz --global install poetry -i https://pypi.tuna.tsinghua.edu.cn/simple \
    && rm -rf /root/.cache \
    && rm -rf /root/.local
RUN useradd -m -s /bin/bash gmh_convert && chown -R gmh_convert:gmh_convert /app
# install dependencies
USER gmh_convert
RUN POETRY_PYPI_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple poetry install --no-cache
# run the app
EXPOSE 8000
CMD ENV_FOR_DYNACONF=production poetry run python main.py run
