| # Use a small Python base image | |
| FROM python:3.10 | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Fast, clean installs | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PORT=7860 | |
| WORKDIR /app | |
| # Copy your app | |
| COPY ./requirements.txt /app/requirements.txt | |
| # Install Python deps | |
| RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
| RUN getent passwd user || useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:${PATH}" | |
| COPY --chown=user . /app | |
| # Expose the port Hugging Face expects | |
| EXPOSE 7860 | |
| # Run your app (it will read $PORT below) | |
| CMD ["gunicorn", "-k", "eventlet", "-w", "1", "-b", "0.0.0.0:7860", "app:app"] |