File size: 729 Bytes
1c3fe08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ---- Docker ----
FROM python:3.10-slim

# HF Spaces runs containers as uid 1000 – create a non-root user
RUN useradd -m -u 1000 appuser

WORKDIR /app

# Install dependencies first (layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Pre-create HF / torch cache dirs writable by appuser
RUN mkdir -p /home/appuser/.cache && chown -R appuser:appuser /home/appuser /app
ENV HF_HOME=/home/appuser/.cache/huggingface

USER appuser

# HF Spaces expects port 7860; local Docker uses PORT env (default 7860)
ENV PORT=7860
EXPOSE 7860

# Run with Uvicorn – 0.0.0.0 so the container is reachable from outside
CMD uvicorn main:app --host 0.0.0.0 --port $PORT