Switch backend Docker image to Alpine multi-stage

This commit is contained in:
Chris
2026-04-03 03:12:19 +08:00
parent 75cf22f7e5
commit ade60bdbaa
2 changed files with 18 additions and 6 deletions

View File

@@ -1,18 +1,29 @@
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
FROM python:3.12-alpine AS builder
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 app /app/app
COPY scripts /app/scripts
COPY README.md /app/README.md
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