# PotholeIQ — Node backend + Python YOLO classifier + Chromium PDF rendering. # Built for HuggingFace Spaces (Docker SDK, app_port 7860) but runs anywhere. FROM node:20-slim # System deps: # - python3 + pip -> YOLOv8 classifier (ai/pothole_server.py) + docx generation # - chromium -> before/after PDF rendering (htmlToPdf) # - libgl1 / libglib2.0 -> OpenCV runtime used by ultralytics # - fonts-liberation -> readable PDF text RUN apt-get update && apt-get install -y --no-install-recommends \ python3 python3-pip \ chromium fonts-liberation \ wkhtmltopdf xvfb \ libgl1 libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # Python deps. CPU-only torch first (much smaller than the default CUDA build). COPY requirements.txt /tmp/requirements.txt RUN pip3 install --no-cache-dir --break-system-packages \ torch torchvision --index-url https://download.pytorch.org/whl/cpu \ && pip3 install --no-cache-dir --break-system-packages -r /tmp/requirements.txt WORKDIR /app # Node deps (cached layer) COPY package.json package-lock.json ./ RUN npm ci --omit=dev # App code (see .dockerignore for exclusions — no secrets, no local data) COPY . . # Runtime env. PORT 7860 is what HuggingFace Spaces routes to. ENV PORT=7860 \ HOST=0.0.0.0 \ PYTHON_BIN=python3 \ CHROME_PATH=/usr/bin/chromium \ YOLO_CONFIG_DIR=/tmp/ultralytics # HF Spaces runs the container as an arbitrary non-root user; make the app dir # writable for the ephemeral data store (data/cases.json etc.). RUN mkdir -p /app/data && chmod -R 777 /app/data && chmod 1777 /tmp EXPOSE 7860 CMD ["node", "server.js"]