File size: 1,859 Bytes
30a02c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # syntax=docker/dockerfile:1.6
FROM python:3.11-slim
# ---------------------------------------------------------------
# System setup
# ---------------------------------------------------------------
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PORT=7860 \
POLL_INTERVAL=10 \
UPSTREAM_API=https://dooratre-db.hf.space
# Minimal build deps (eventlet/greenlet sometimes need them on slim)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# ---------------------------------------------------------------
# Non-root user (HF Spaces friendly)
# ---------------------------------------------------------------
RUN useradd -m -u 1000 appuser
WORKDIR /app
# ---------------------------------------------------------------
# Python deps (cache layer)
# ---------------------------------------------------------------
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt
# ---------------------------------------------------------------
# App source
# ---------------------------------------------------------------
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fsS http://localhost:7860/health || exit 1
# ---------------------------------------------------------------
# Run with gunicorn + eventlet worker for Socket.IO
# ---------------------------------------------------------------
CMD ["gunicorn", \
"-k", "eventlet", \
"-w", "1", \
"--bind", "0.0.0.0:7860", \
"--access-logfile", "-", \
"--error-logfile", "-", \
"--timeout", "120", \
"app:app"] |