Spaces:
Sleeping
Sleeping
yonnel
Enhance HF cache setup and error handling in vector storage; add local backup functionality for vector saving
2f58804
FROM python:3.9-slim | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
gcc \ | |
g++ \ | |
curl \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Copy requirements first for better caching | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy application code | |
COPY app/ ./app/ | |
# Create data directory and cache directories with proper permissions | |
RUN mkdir -p app/data && chmod 777 app/data | |
RUN mkdir -p /tmp/hf_cache && chmod 777 /tmp/hf_cache | |
RUN mkdir -p /app/.cache && chmod 777 /app/.cache | |
# Set environment variables for HF cache | |
ENV HF_HOME=/tmp/hf_cache | |
ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache | |
ENV TRANSFORMERS_CACHE=/tmp/hf_cache | |
# Make start script executable | |
RUN chmod +x app/start.py | |
# Expose port | |
EXPOSE 7860 | |
# Health check with longer timeout for initial build | |
HEALTHCHECK --interval=30s --timeout=30s --start-period=300s --retries=3 \ | |
CMD curl -f http://localhost:7860/health || exit 1 | |
# Run the startup script that builds index if needed, then starts the API | |
CMD ["python", "app/start.py"] |