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"]