Spaces:
Running
Running
File size: 767 Bytes
cb0afeb 4435dd1 cb0afeb 4435dd1 bbda247 4435dd1 cb0afeb 4435dd1 cb0afeb 4435dd1 cb0afeb 9d1b549 cb0afeb |
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.10-slim
# Create a non-root user for Spaces (UID 1000 is the default)
RUN useradd -m -u 1000 user
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Make sure cache directories exist and are writable by non-root user
RUN mkdir -p /tmp/huggingface && chown -R user:user /tmp/huggingface
# Environment variables must be set before any Python code runs
ENV HF_HOME=/tmp/huggingface \
HF_DATASETS_CACHE=/tmp/huggingface/datasets \
HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub \
TRANSFORMERS_CACHE=/tmp/huggingface/transformers \
XDG_CACHE_HOME=/tmp/huggingface \
PYTHONUNBUFFERED=1
USER user
WORKDIR /app
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|