FROM python:3.12-slim

RUN apt-get update && apt-get install --no-install-recommends -y libolm3 libolm-dev git libmagic-dev ffmpeg && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -U "yt-dlp[default,curl-cffi]"

COPY . .

WORKDIR /runtime
RUN chown -R 1000:1000 /usr/src /runtime

USER 1000:1000
CMD [ "python", "/usr/src/app/main.py" ]