# Hugging Face Space (Docker SDK). PORT is set by the platform (default 7860). # Bump this comment to force a no-cache rebuild when Hub serves stale static assets or README Space config. FROM python:3.12-slim-bookworm WORKDIR /app ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/app ENV KINK_STORE_PATH=/tmp/kink_store.db ENV KINK_SEED_PATH=/app/deploy/hf/seed/hf_bundled_store.db # Default: bundled seed in the image (fast boot, reliable on cpu-basic). For a full Hub catalog, set Space variables # e.g. KINK_HF_REQUIRE_FULL_CATALOG=1, KINK_HF_DATASET_REPO=owner/dataset, KINK_HF_DATASET_FILENAME=store_slim.db, HF_TOKEN if private. ENV KINK_HF_REQUIRE_FULL_CATALOG=0 # cpu-basic Spaces cap RAM at 16Gi; full PPR / similarity-graph warm often OOMs without this. # Catalog is still built at boot. Override to 0 on larger hardware for full graph warm-up. ENV KINK_SKIP_HEAVY_WARM=1 # Missing FetLife mirrors must serve the bundled JPEG placeholder (do not set KINK_MEDIA_STRICT on HF). ENV KINK_MEDIA_STRICT=0 # Set only in this image; api.py treats missing /media tiles as placeholder-eligible even if a Space # secret sets KINK_MEDIA_STRICT=1 or a bad KINK_MEDIA_FALLBACK_PATH (see _media_strict_missing). ENV KINK_HF_SPACE_IMAGE=1 COPY . /app RUN apt-get update \ && apt-get install -y --no-install-recommends nodejs npm \ && rm -rf /var/lib/apt/lists/* \ && npm ci \ && npm run build \ && pip install --no-cache-dir pip setuptools wheel \ && pip install --no-cache-dir . \ && chmod +x /app/deploy/hf/entrypoint.sh EXPOSE 7860 ENTRYPOINT ["/app/deploy/hf/entrypoint.sh"]