Presets / Python 3.12 + FastAPI (uvicorn)
preset Python

Python 3.12 + FastAPI (uvicorn)

dockerfile  ·  Python

FastAPI + Uvicorn en image slim, utilisateur non-root.

python fastapi uvicorn api
FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN useradd -m app && chown -R app:app /app
USER app

EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]