Spaces:
Sleeping
Sleeping
| # ββ Hugging Face Spaces β Docker Runtime βββββββββββββββββββββββββββββββββββββ | |
| # Python 3.11 slim keeps the image lean while supporting all crewai deps. | |
| FROM python:3.11.9-slim | |
| # Prevent .pyc files and force unbuffered stdout/stderr (crucial for HF logs) | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 | |
| WORKDIR /app | |
| # ββ System deps required by crewai / grpc / tiktoken βββββββββββββββββββββββββ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| libffi-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ββ Python deps (cached layer β only rebuilds when requirements.txt changes) ββ | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # ββ Application files βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY app.py . | |
| COPY index.html . | |
| # ββ Memory file: pre-create so the container can write to it immediately ββββββ | |
| # On HF Spaces the filesystem is ephemeral, but this ensures the file exists | |
| # on first boot without any code-level FileNotFoundError. | |
| RUN echo "[]" > /app/memory.json | |
| # ββ Hugging Face Spaces REQUIRES port 7860 ββββββββββββββββββββββββββββββββββββ | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # ββ Gunicorn config βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # 1 worker + 8 threads β ideal for HF single-instance Spaces | |
| # timeout 300 β multi-agent CrewAI runs can take 2-4 min | |
| # graceful-timeout 10 β clean shutdown on redeploy | |
| CMD exec gunicorn \ | |
| --bind "0.0.0.0:7860" \ | |
| --workers 1 \ | |
| --threads 8 \ | |
| --timeout 300 \ | |
| --graceful-timeout 10 \ | |
| --log-level info \ | |
| --access-logfile - \ | |
| --error-logfile - \ | |
| app:app | |