# Use a lightweight Python image FROM python:3.10-slim # Set working directory WORKDIR /app # Set environment variables for Hugging Face cache ENV HF_HOME=/tmp/huggingface ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libgl1-mesa-glx \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ wget \ git \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create necessary directories with appropriate permissions RUN mkdir -p /tmp/uploads /tmp/results /tmp/huggingface/transformers /tmp/huggingface/datasets \ && chmod -R 777 /tmp/uploads /tmp/results /tmp/huggingface # Copy requirements file and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -U pip && \ pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . # Expose the port the app runs on (standard for Hugging Face Spaces) EXPOSE 7860 # Command to run the application CMD ["python", "app.py"]