# Textilindo AI Assistant - Hugging Face Spaces Docker Setup # Based on Hugging Face Spaces documentation FROM python:3.9-slim # Create user for security RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Install system dependencies USER root RUN apt-get update && apt-get install -y \ git \ curl \ build-essential \ && rm -rf /var/lib/apt/lists/* # Switch back to user USER user # Copy requirements first for better caching COPY --chown=user ./requirements.txt requirements.txt # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip RUN pip install --no-cache-dir --user -r requirements.txt # Copy application files COPY --chown=user . /app # Create necessary directories RUN mkdir -p /app/models /app/data /app/configs /app/logs /app/templates # Set environment variables ENV PYTHONPATH=/app ENV HF_HOME=/app/.cache/huggingface ENV TRANSFORMERS_CACHE=/app/.cache/transformers # Expose port 7860 (required for Hugging Face Spaces) EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run the application CMD ["python", "app.py"]