check-in-API / Dockerfile
mjpsm's picture
Update Dockerfile
d568343 verified
raw
history blame contribute delete
727 Bytes
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"]