FROM python:3.9 # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y espeak-ng # Set writable cache directories ENV HF_HOME="/app/.cache/huggingface" ENV XDG_CACHE_HOME="/app/.cache" ENV PIP_CACHE_DIR="/app/.cache/pip" ENV TRANSFORMERS_CACHE="/app/.cache/huggingface" # Ensure cache directories exist and have correct permissions RUN mkdir -p $HF_HOME $XDG_CACHE_HOME $PIP_CACHE_DIR $TRANSFORMERS_CACHE && chmod -R 777 /app/.cache # Copy requirements first to leverage Docker cache COPY requirements.txt . # Upgrade pip and install dependencies globally (without --user) RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Install SpaCy model explicitly under /app to avoid permission issues RUN python -m spacy download en_core_web_sm # Copy project files COPY . . # Ensure Flask is installed RUN python -m pip show flask # Run the Flask app CMD ["python", "app.py"]