Switch backend Docker image to Alpine multi-stage
This commit is contained in:
23
Dockerfile
23
Dockerfile
@@ -1,18 +1,29 @@
|
|||||||
FROM python:3.12-slim
|
FROM python:3.12-alpine AS builder
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
||||||
PYTHONUNBUFFERED=1
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install runtime dependencies from local package metadata.
|
RUN apk add --no-cache build-base libffi-dev openssl-dev cargo
|
||||||
|
|
||||||
COPY pyproject.toml /app/pyproject.toml
|
COPY pyproject.toml /app/pyproject.toml
|
||||||
COPY app /app/app
|
COPY app /app/app
|
||||||
COPY scripts /app/scripts
|
COPY scripts /app/scripts
|
||||||
COPY README.md /app/README.md
|
COPY README.md /app/README.md
|
||||||
|
|
||||||
RUN pip install --no-cache-dir --upgrade pip && \
|
RUN pip install --no-cache-dir --upgrade pip && \
|
||||||
pip install --no-cache-dir .
|
pip wheel --no-cache-dir --wheel-dir /wheels .
|
||||||
|
|
||||||
|
FROM python:3.12-alpine
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache libstdc++ libffi openssl
|
||||||
|
|
||||||
|
COPY --from=builder /wheels /wheels
|
||||||
|
RUN pip install --no-cache-dir --upgrade pip && \
|
||||||
|
pip install --no-cache-dir /wheels/*
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user