Spaces:
Sleeping
Sleeping
Download Dockerfile from Metatron2030/superkart-api: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/spaces/Metatron2030/superkart-api/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Metatron2030/superkart-api/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Metatron2030/superkart-api/resolve/main/Dockerfile
2.39 kB
| # ββ Base: exact patch version matching the training interpreter (Β§1) ββββββ | |
| # NOT alpine: musl libc has no manylinux wheels, so NumPy/SciPy would | |
| # compile from source and can differ numerically. | |
| FROM python:3.12-slim | |
| # ββ Interpreter behaviour. Metadata only β no layer, never invalidated. βββ | |
| # PYTHONUNBUFFERED is not cosmetic: without it logs sit in a buffer and | |
| # vanish when the container is killed, exactly when they are needed. | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 | |
| # ββ System libraries. One RUN, cleanup inside it, so the apt lists never ββ | |
| # enter a layer. curl is needed by HEALTHCHECK. | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ββ Non-root user. HF Spaces expect uid 1000. ββββββββββββββββββββββββββββ | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /home/user/app | |
| # ββ THE CACHE BOUNDARY: manifest alone, then install. ββββββββββββββββββββ | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ββ Volatile files last. Edits here never re-run the install above. ββββββ | |
| # superkart_features.py MUST be present: the pipeline's FunctionTransformer | |
| # references engineer() by module path, and joblib.load fails without it. | |
| COPY --chown=user superkart_features.py . | |
| COPY --chown=user superkart_model_v1.joblib . | |
| COPY --chown=user golden_sample.json model_manifest.json ./ | |
| COPY --chown=user app.py gunicorn.conf.py ./ | |
| # ββ Contract with the platform βββββββββββββββββββββββββββββββββββββββββββ | |
| EXPOSE 7860 | |
| # start-period is generous: a 37 MB artefact must deserialize and pass the | |
| # golden-sample check before the first probe counts against the retry budget. | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ | |
| CMD curl -fsS http://localhost:7860/health || exit 1 | |
| # ββ Exec form: gunicorn is PID 1, so SIGTERM reaches it and shutdown is ββ | |
| # graceful. Shell form would put /bin/sh at PID 1, which swallows signals. | |
| CMD ["gunicorn", "--config", "gunicorn.conf.py", "app:app"] | |