File size: 868 Bytes
d64524a
 
 
 
 
 
95079b7
d64524a
 
 
 
 
 
 
 
 
 
 
95079b7
 
 
 
d64524a
 
 
bec871e
 
d64524a
 
bec871e
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
FROM python:3.12.1-slim-bookworm

# Install uv by copying it directly from its container image (much faster and smaller than pip)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

# Install uv (the fast package manager)
# This step is technically redundant if the COPY above works, but we'll keep it.
RUN pip install uv

# Set the working directory
WORKDIR /app

# Copy dependency files
COPY pyproject.toml uv.lock ./

# Install dependencies from the lock file
RUN uv sync --frozen --no-cache

# The .venv is located inside the WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH"
# ====================================

# Copy the FastAPI app and model
COPY predict.py model.bin ./

# Expose port (optional but good practice, 7860 for HF Spaces)
EXPOSE 7860

# Start the FastAPI app with uvicorn
ENTRYPOINT ["uvicorn", "predict:app", "--host", "0.0.0.0", "--port", "7860"]