File size: 798 Bytes
8dd54fd
 
 
 
 
8ca07e8
8dd54fd
 
8ca07e8
 
 
8dd54fd
8ca07e8
 
 
8dd54fd
8ca07e8
 
8dd54fd
 
 
 
 
eae8877
8ca07e8
8dd54fd
8ca07e8
 
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
FROM python:3.12-slim-bookworm

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Create non-root user (Hugging Face requirement)
RUN useradd -m -u 1000 user

# Set working directory to the user's home folder
WORKDIR /home/user/app
RUN chown user:user /home/user/app

# Switch to the user BEFORE installing dependencies!
# This ensures the .venv is owned by 'user', not 'root'.
USER user

# ---- Dependency layer (cached) ----
COPY --chown=user:user pyproject.toml uv.lock ./
RUN uv sync --frozen --no-cache

# ---- Application code ----
COPY --chown=user:user . .

# Hugging Face explicitly requires exposing 7860, that's why exposing here
EXPOSE 7860

# Run Uvicorn directly on port 7860
CMD ["uv", "run", "uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "7860"]