lite-start
This commit is contained in:
@@ -1,20 +1,36 @@
|
||||
# syntax=docker/dockerfile:1.5
|
||||
FROM python:3.14-slim AS base
|
||||
|
||||
# Builder: install build deps and build wheels
|
||||
FROM python:3.14-slim AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Устанавливаем системные зависимости
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
aria2 \
|
||||
ca-certificates \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Копируем requirements и устанавливаем все Python-зависимости (по умолчанию все нужны)
|
||||
COPY requirements.txt .
|
||||
COPY requirements.txt ./
|
||||
# Build wheels into /wheels (use cache for pip downloads)
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install --no-cache-dir -r requirements.txt
|
||||
pip wheel --no-cache-dir -r requirements.txt -w /wheels
|
||||
|
||||
|
||||
# Final image: small and without build tools
|
||||
FROM python:3.14-slim AS final
|
||||
WORKDIR /app
|
||||
|
||||
# minimal runtime deps
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
aria2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy wheels from builder and install
|
||||
COPY --from=builder /wheels /wheels
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install --no-cache-dir /wheels/* || pip install --no-cache-dir /wheels/* --no-deps
|
||||
|
||||
# Copy application code (exclude models/data via .dockerignore)
|
||||
COPY . ./api
|
||||
|
||||
CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Reference in New Issue
Block a user