FROM python:3.12-slim-bookworm AS base ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ YTDLP_NO_PLUGINS=1 WORKDIR /app RUN apt-get update \ && apt-get install --yes --no-install-recommends ffmpeg \ && rm -rf /var/lib/apt/lists/* RUN groupadd --gid 10001 app \ && useradd --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app COPY requirements.txt ./ RUN pip install --no-cache-dir --requirement requirements.txt FROM base AS test COPY requirements-dev.txt pyproject.toml ./ RUN pip install --no-cache-dir --requirement requirements-dev.txt COPY --chown=app:app app ./app COPY --chown=app:app tests ./tests USER app CMD ["pytest"] FROM base AS runtime COPY --chown=app:app app ./app USER app EXPOSE 8000 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]