Parallelise Dockerfile stages and enable CI layer caching
Split runtime apt-get into a separate stage so BuildKit runs it concurrently with the builder's apt-get + pip install. Add cache_from to the Drone CI API build step to reuse layers from the previous image.
This commit is contained in:
parent
3ef2df63b9
commit
7e05b3c971
2 changed files with 7 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Stage 1: Build dependencies
|
||||
# Stage 1: Install build tools and Python dependencies
|
||||
FROM python:3.13-slim AS builder
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
|
|
@ -17,10 +17,9 @@ COPY requirements.txt ./
|
|||
RUN python -m venv /app/.venv && \
|
||||
/app/.venv/bin/pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Stage 2: Runtime image
|
||||
FROM python:3.13-slim
|
||||
# Stage 2: Runtime system dependencies (runs in parallel with builder)
|
||||
FROM python:3.13-slim AS runtime-base
|
||||
|
||||
# Install only runtime system dependencies (no build tools)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
|
|
@ -29,6 +28,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||
libmariadb3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Stage 3: Final image — combine venv from builder + runtime base
|
||||
FROM runtime-base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the venv from the builder stage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue