File size: 727 Bytes
35a8807
 
d568343
 
 
 
 
 
 
 
 
35a8807
 
 
d568343
35a8807
 
 
d568343
35a8807
d568343
35a8807
 
d568343
35a8807
 
d568343
35a8807
d568343
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.10-slim

# Create writable cache directory for Hugging Face
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface

# Set environment variables globally (before Python starts)
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets
ENV XDG_CACHE_HOME=/tmp/huggingface

# Set working directory
WORKDIR /app

# Copy dependencies
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir fastapi uvicorn transformers torch

# Copy the FastAPI app
COPY app.py .

# Expose the port expected by Hugging Face Spaces
EXPOSE 7860

# Run FastAPI server
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]