31 lines
695 B
Docker
31 lines
695 B
Docker
FROM python:3.10-slim as builder
|
|
|
|
WORKDIR /app
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
COPY requirements.txt .
|
|
RUN --mount=type=cache,target=/root/.cache/pip pip wheel --no-deps --wheel-dir /app/wheels -r requirements.txt
|
|
|
|
|
|
|
|
FROM python:3.10-slim
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
RUN useradd -ms /bin/bash user && apt update && apt install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/wheels /wheels
|
|
COPY --from=builder /app/requirements.txt .
|
|
|
|
RUN pip install --no-cache /wheels/*
|
|
USER user
|
|
|
|
COPY . .
|
|
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
|