File size: 857 Bytes
a4f8eb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04

RUN apt-get update && apt-get install -y \
    python3 python3-pip git \
    && rm -rf /var/lib/apt/lists/*

RUN pip3 install --no-cache-dir \
    flask flask-cors \
    torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 \
    numpy transformers accelerate sentencepiece protobuf

# Create non-root user (HF Spaces runs as uid 1000)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface

WORKDIR /home/user/app
COPY --chown=user:user . .

# Pre-download model during build (avoids slow cold start)
RUN python3 -c "from transformers import AutoModel; AutoModel.from_pretrained('ShandaAI/FloodDiffusionTiny', trust_remote_code=True)"

EXPOSE 7860
CMD ["python3", "app.py", "--port", "7860"]