From 7e05b3c9712d1effc350c3c7cbcfbd4b5daa8273 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sat, 7 Feb 2026 11:06:35 +0000 Subject: [PATCH] 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. --- .drone.yml | 1 + crawler/Dockerfile | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 12c69c5..05c918a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -58,6 +58,7 @@ steps: dockerfile: crawler/Dockerfile context: crawler/ auto_tag: true + cache_from: viktorbarzin/realestatecrawler:latest - name: Update deployment image: alpine diff --git a/crawler/Dockerfile b/crawler/Dockerfile index 7318313..570190e 100644 --- a/crawler/Dockerfile +++ b/crawler/Dockerfile @@ -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