-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 1.1 KB
/
Copy pathDockerfile
File metadata and controls
33 lines (23 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# ── Stage 1: build deps ──────────────────────────────────────────────
FROM python:3.11-slim AS builder
WORKDIR /app
# System deps for building wheels (numpy, torch, etc.)
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc g++ && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
# Install CPU-only PyTorch first to keep the image small, then the rest
RUN pip install --no-cache-dir --prefix=/install \
torch --index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: runtime ────────────────────────────────────────────────
FROM python:3.11-slim
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy application code
COPY . .
# Expose the default uvicorn port
EXPOSE 8000
# Run the FastAPI app
CMD ["uvicorn", "API:app", "--host", "0.0.0.0", "--port", "8000"]