36 lines
1.1 KiB
Docker
36 lines
1.1 KiB
Docker
# syntax=docker/dockerfile:1.5
|
|
|
|
# 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 \
|
|
build-essential \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY requirements.txt ./
|
|
# Build wheels into /wheels (use cache for pip downloads)
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
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"] |