# Hugging Face Spaces runs this as the container entrypoint (sdk: docker). # HF exposes port 7860 and runs the container as a non-root user (uid 1000), # so we install deps as root, then chown the app so runtime writes (e.g. the # subscribers CSV) don't hit a permission error. FROM python:3.11-slim ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ MPLCONFIGDIR=/tmp/mpl \ PORT=7860 WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . RUN useradd -m -u 1000 appuser \ && mkdir -p /app/data \ && chown -R appuser:appuser /app USER appuser EXPOSE 7860 CMD ["gunicorn", "webapp.app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "120"]