FROM python:3.9-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ HF_HOME=/tmp/cache \ TORCH_HOME=/tmp/cache \ FLASK_APP=app.py \ TOKENIZERS_PARALLELISM=false \ DATABASE_URL=sqlite:////tmp/news.db # Create cache directory with proper permissions RUN mkdir -p /tmp/cache && \ touch /tmp/news.db && \ chmod -R 777 /tmp # Install system dependencies including accelerate RUN apt-get update && \ apt-get install -y --no-install-recommends \ gcc \ python3-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -U pip && \ pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 7860 CMD ["gunicorn", "app:app", \ "--bind", "0.0.0.0:7860", \ "--workers", "1", \ "--timeout", "300", \ "--worker-class", "gevent"]