From fd931f1cfce75e3e1f51fe4125b54e33eaa2769e Mon Sep 17 00:00:00 2001 From: fchinembiri Date: Fri, 8 May 2026 18:25:19 +0200 Subject: [PATCH] optimize: use pre-built PyTorch base image for worker to reduce build overhead --- apps/worker/Dockerfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/worker/Dockerfile b/apps/worker/Dockerfile index 72ba7cd..dfa9203 100644 --- a/apps/worker/Dockerfile +++ b/apps/worker/Dockerfile @@ -1,6 +1,10 @@ -FROM python:3.11-slim +# Use pre-built PyTorch image to avoid massive downloads and build overhead +FROM pytorch/pytorch:2.1.1-cuda12.1-cudnn8-runtime -# Install system dependencies required by rasterio and other packages +# Set non-interactive for apt +ENV DEBIAN_FRONTEND=noninteractive + +# Install system dependencies and clean up in one layer RUN apt-get update && apt-get install -y --no-install-recommends \ libexpat1 \ libgomp1 \ @@ -10,6 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libspatialindex-dev \ libcurl4-openssl-dev \ libssl-dev \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* WORKDIR /app @@ -17,10 +22,13 @@ WORKDIR /app # Set Python path to include /app ENV PYTHONPATH=/app +# Copy requirements and install dependencies +# We use --no-cache-dir to keep the image small COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +# Copy the application code COPY . . -# Start the RQ worker to listen for jobs on the geocrop_tasks queue +# Start the RQ worker CMD ["python", "worker.py", "--worker"]