diff --git a/Dockerfile b/Dockerfile index 89ed8c0..12b0e62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,20 @@ WORKDIR /app # image-search fallback (see requirements.txt); run `playwright install # chromium` in the container if you need that specific fallback tier. COPY requirements.txt . + +# torch is installed FIRST, from PyTorch's CPU-only index, and that ordering is +# the point. sentence-transformers pulls torch in transitively, and pip's +# default wheel for Linux bundles the entire CUDA stack - cuBLAS, cuDNN, NVRTC, +# Triton - because it cannot know the target has no GPU. Measured in this image +# it was 2.7GB of nvidia/ plus 691MB of triton/, none of which can ever execute +# on a CPU-only VPS, in a 9.2GB image on a 48GB disk shared with a dozen +# services. A build here has already failed once on "no space left on device". +# +# Installing it up front means the requirements.txt pass below finds torch +# already satisfied and leaves it alone. Keep these two steps in this order. RUN python -m venv /opt/venv \ + && /opt/venv/bin/pip install --no-cache-dir \ + --index-url https://download.pytorch.org/whl/cpu torch \ && /opt/venv/bin/pip install --no-cache-dir -r requirements.txt diff --git a/requirements.txt b/requirements.txt index ffa93d6..6783c53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -52,7 +52,13 @@ aiofiles>=23.2.1 # Playwright (Python) - last-resort image-search fallback only. # Run `playwright install chromium` once after pip install to enable it; # the pipeline works fine without it (just one fewer fallback source). -playwright>=1.47.0 +# playwright>=1.47.0 +# Commented out, not deleted. It is the last-resort image-search tier, and the +# Dockerfile never installs its browser binary - so in a container the tier is +# skipped at runtime no matter what, while the package still costs 137MB. The +# import is lazy (app/services/playwright_image_fallback.py does it inside the +# function), so its absence is handled on the existing "not installed" path. +# Uncomment, and run `playwright install chromium`, if you ever want that tier. # --- S3 / DigitalOcean Spaces (optional product image storage) --- boto3>=1.34.162