update Dockerfile

This commit is contained in:
denis 2026-09-18 18:13:44 +03:00
parent 970c49599f
commit 68371f826b
1 changed files with 17 additions and 11 deletions

View File

@ -1,11 +1,19 @@
FROM python:3.10-slim
# --- Этап сборки ---
FROM python:3.10-slim AS builder
# Неинтерактивный режим для apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt \
--extra-index-url https://download.pytorch.org/whl/cpu
# Системные зависимости для OpenCV и Pillow
# --- Финальный этап ---
FROM python:3.10-slim
# Только runtime-библиотеки, без gcc
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglx-mesa0 \
@ -14,20 +22,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libxext6 \
libxrender1 \
libgomp1 \
wget \
&& rm -rf /var/lib/apt/lists/*
# Python-зависимости
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
--extra-index-url https://download.pytorch.org/whl/cpu
WORKDIR /app
# Копируем установленные пакеты из builder-этапа
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
# Проект
COPY . .
RUN mkdir -p models
EXPOSE 8000
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app