Spaces:
Running
Running
# Use Python 3.10 or later | |
FROM python:3.10 | |
# Set the working directory | |
WORKDIR /app | |
# Set environment variables for Hugging Face | |
ENV HF_HOME=/huggingface | |
ENV TRANSFORMERS_CACHE=/huggingface/cache | |
ENV HF_HUB_ENABLE_HF_TRANSFER=1 | |
ENV HF_HUB_CACHE_DIR=/huggingface/cache | |
# Create cache directories with appropriate permissions | |
RUN mkdir -p /huggingface/cache && \ | |
chmod -R 777 /huggingface | |
# Copy only requirements first to leverage Docker cache | |
COPY requirements.txt . | |
RUN pip install -r requirements.txt | |
# Copy the rest of the application | |
COPY app.py . | |
# Create a volume for the cache | |
VOLUME ["/huggingface/cache"] | |
# Expose port for FastAPI | |
EXPOSE 7860 | |
# Run FastAPI app | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |