2026-08-11 14:44:59 +03:00
|
|
|
FROM python:3.12-slim-bookworm AS base
|
|
|
|
|
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
|
PYTHONUNBUFFERED=1 \
|
2026-08-11 15:19:35 +03:00
|
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
|
|
|
|
YTDLP_NO_PLUGINS=1
|
2026-08-11 14:44:59 +03:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-08-11 15:19:35 +03:00
|
|
|
RUN apt-get update \
|
|
|
|
|
&& apt-get install --yes --no-install-recommends ffmpeg \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2026-08-11 14:44:59 +03:00
|
|
|
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"]
|