| FROM python:3.12-slim | |
| # Installa distutils (e setuptools se vuoi) | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| python3-distutils \ | |
| python3-setuptools \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Crea utente non privilegiato | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Copia il file requirements.txt e installa i pacchetti | |
| COPY --chown=user: ./requirements.txt requirements.txt | |
| RUN pip install --upgrade pip | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copia il resto del codice | |
| COPY --chown=user: . /app | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |