FROM python:3.11-slim ENV DEBIAN_FRONTEND=noninteractive \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 # deps untuk psycopg2-binary & build wheels RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential git curl libpq-dev && \ rm -rf /var/lib/apt/lists/* WORKDIR /app # install deps dulu (cache layer) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # copy source COPY . . # port default Spaces ENV PORT=7860 # start gunicorn CMD ["gunicorn", "-w", "1", "-k", "gthread", "-t", "180", "-b", "0.0.0.0:7860", "app:app"]