Spaces:
Sleeping
Sleeping
File size: 1,651 Bytes
45e997f 9006385 45e997f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # 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"]
|