FROM python:3.12-slim AS build WORKDIR /build COPY requirements.txt . RUN pip install --prefix=/install --no-cache-dir -r requirements.txt FROM python:3.12-slim ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 RUN useradd --system --uid 1000 --home /app --create-home app WORKDIR /app COPY --from=build /install /usr/local COPY app ./app USER app CMD ["python", "-m", "app.main"]