28 lines
582 B
Docker
28 lines
582 B
Docker
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip
|
|
|
|
COPY requirements.txt .
|
|
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
|
|
|
|
# ---
|
|
FROM python:3.12-alpine AS runtime
|
|
|
|
RUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001 -G appgroup
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /wheels /wheels
|
|
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
|
|
|
|
COPY --chown=appuser:appgroup main.py .
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|