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:
Viktor Barzin 2026-02-07 11:06:35 +00:00
parent 3ef2df63b9
commit 7e05b3c971
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 7 additions and 4 deletions

View file

@ -58,6 +58,7 @@ steps:
dockerfile: crawler/Dockerfile
context: crawler/
auto_tag: true
cache_from: viktorbarzin/realestatecrawler:latest
- name: Update deployment
image: alpine

View file

@ -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