Spaces:
Sleeping
Sleeping
| # Use the official Python image | |
| FROM python:3.9 | |
| # Add a non-root user and set up the environment | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Set Hugging Face cache directory and disable tokenizer parallelism | |
| ENV HF_HOME=/app/hf_cache | |
| ENV TOKENIZERS_PARALLELISM=false | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy dependencies first for caching | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Create cache directory for Hugging Face and ensure permissions | |
| RUN mkdir -p /app/hf_cache && chown user:user /app/hf_cache | |
| # Copy the rest of the application files | |
| COPY --chown=user . /app | |
| # Start Gunicorn with increased timeout and multiple workers | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "300", "--workers", "2", "chatbot:app"] | |