File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1- FROM python:3.11-slim
1+ # ---------- Stage 1: Build dependencies ----------
2+ FROM python:3.11-slim AS builder
23
34WORKDIR /app
45
5- # Install minimal system dependencies
66RUN apt-get update && apt-get install -y --no-install-recommends \
77 build-essential \
88 libopenblas-dev \
@@ -13,8 +13,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1313COPY req.txt .
1414
1515RUN pip install --upgrade pip \
16- && pip install --no-cache-dir -r req.txt
16+ && pip install --no-cache-dir -r req.txt \
17+ && pip install --no-cache-dir uvicorn
18+
19+ # ---------- Stage 2: Final lightweight image ----------
20+ FROM python:3.11-slim
21+
22+ WORKDIR /app
23+
24+ # Copy only installed packages (fast!)
25+ COPY --from=builder /usr/local /usr/local
1726
27+ # Copy app code
1828COPY . .
1929
2030EXPOSE 8000
You can’t perform that action at this time.
0 commit comments