Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
davanstrien HF Staff
Port to FastAPI + Granian Docker Space: /api/* JSON routes, fetch() frontend, single supervised ingest worker (file lock + wait for previous worker)
ddfb9e0 verified Download Dockerfile from davanstrien/topic-feed-lab: direct link, hf CLI and curl.
- Browser
- Download file 706 Bytes
-
https://huggingface.co/spaces/davanstrien/topic-feed-lab/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/davanstrien/topic-feed-lab/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/davanstrien/topic-feed-lab/resolve/main/Dockerfile
706 Bytes
| FROM python:3.12-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| HF_HOME=/tmp/hf \ | |
| FIREHOSE_DIR=/data | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /home/user/app | |
| # CPU-only torch for the ingest worker (GLiNER2.5-Decide); gliner2 pins transformers<5 / huggingface_hub<1.0. | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --extra-index-url https://download.pytorch.org/whl/cpu -r requirements.txt | |
| COPY --chown=user . . | |
| USER user | |
| EXPOSE 7860 | |
| # One Granian worker process: the app supervises the single ingest worker (single-writer rule for the bucket). | |
| CMD ["granian", "--interface", "asgi", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", \ | |
| "--runtime-threads", "2", "app:app"] | |