Spaces:
Sleeping
Sleeping
Download Dockerfile from kshitiz14/product_attribute: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/kshitiz14/product_attribute/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/kshitiz14/product_attribute/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/kshitiz14/product_attribute/resolve/main/Dockerfile
1.51 kB
| # Product Attribute Extraction API - Docker image | |
| # Compatible with Hugging Face Docker Spaces (port 7860, non-root user) | |
| # and with plain local `docker run` / docker-compose. | |
| FROM python:3.12-slim | |
| # HF Spaces containers run as a non-root user; create one matching their | |
| # convention (uid 1000) so file permissions work whether this builds on | |
| # HF Spaces or locally. | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # System deps kept minimal; scikit-learn wheels are pure-python/precompiled | |
| # so no build-essential is needed on slim. | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy project | |
| COPY --chown=user data/ ./data/ | |
| COPY --chown=user src/ ./src/ | |
| COPY --chown=user app.py . | |
| USER user | |
| # Build the labeled dataset and train the model at image build time, so the | |
| # container starts up with a ready-to-serve model.joblib baked in (no | |
| # training step needed at runtime/startup). | |
| RUN cd data && python3 build_dataset.py && cd ../src && python3 train.py | |
| # Hugging Face Docker Spaces require the app to listen on port 7860. | |
| EXPOSE 7860 | |
| # Basic container healthcheck against the /health endpoint. | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ | |
| CMD python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 1 | |
| # app.py at the repo root is the entrypoint (HF Spaces convention); it | |
| # wires up the extraction pipeline living in src/. | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |