Spaces:
Runtime error
Runtime error
| # Use an official Python runtime as a parent image | |
| FROM python:3.9-slim | |
| # Disable Python buffering for easier container logging | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set environment variables for writable caches and config directories | |
| ENV HOME=/tmp | |
| ENV XDG_CACHE_HOME=/tmp/.cache | |
| ENV MPLCONFIGDIR=/tmp/matplotlib | |
| ENV HF_HOME=/tmp/hf_home | |
| # Optional: Force Transformers to use slow tokenizers | |
| ENV TRANSFORMERS_NO_FAST=1 | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install system dependencies including build-essential for gcc | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| ffmpeg \ | |
| libsm6 \ | |
| libxext6 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file into the container | |
| COPY requirements.txt /app/requirements.txt | |
| # Upgrade pip and install Python dependencies | |
| RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt | |
| # Download spaCy's small English model | |
| RUN python -m spacy download en_core_web_sm | |
| # Create required directories with proper permissions | |
| RUN mkdir -p /app/static /app/temp && chmod -R 777 /app/static /app/temp | |
| # Copy the rest of your application code into the container | |
| COPY . /app | |
| # Set permissions for the entire /app directory (adjust for security if needed) | |
| RUN chmod -R 777 /app | |
| # Set a default port; Hugging Face Spaces sets PORT automatically | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Run the FastAPI application using uvicorn on the dynamic port | |
| CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT}"] | |